Browse files

export1 on 20100219-09:10:23

  • Loading branch information...
1 parent e7bf5f3 commit 89c861949a454c41825c75349646bf8fd9a82dd9 @jakobi committed Feb 19, 2010
View
15 admin.text/sfre
@@ -48,9 +48,16 @@ our $changetrackcmd='changetrack';
#
# To be implemented/changed:
#
+# - allow a switch to set/ask user for an after-editing-comment
+# (as he might reconsider and the initial entry is bogus)
+# [[possibly also a variant to set/edit the previous entry when rerun
+# with the same params?? or is history editing just EDIT THE LOG DIRECTLY
+# from within sfre?]]
# - changetrack file size limits and exclusion (long logs, etc)
# or optional parent proc based exclusion (e.g. invocations from
# emv, crontab -e or similar shouldn't be changetracked)
+# - recognize (anonymous) temp files and don't changetrack them: (regexes)
+# NAME.pid.DATESTRING, (/var)?/tmp/{tmp,file}XXXXXX{*,/*}
# - do I already log the RC of the executed command??? - ADD IT
# - do keep @files in order, but strip dupes (currently lock.pl
# does this for us)
@@ -120,6 +127,14 @@ our $changetrackcmd='changetrack';
# - == both points should do the trick.
# - special handling of vi -R and empty vi invocations
# - DO ask no message, maybe also avoid journaling if no o_message
+# - easier removal/cleanup of changetracked files and dirs
+# maybe just document: getting the RCS path by doing sfre -cat > /dev/null
+# and stripping the hostname-pid-prefix from the RCS output on stderr
+# (the prefix is just to allow parallel access from RCS/changetrack
+# while mangling their files)
+# - mention the stupidly huge filename issue with changetrack's way of
+# encoding dirs in file names, which also affects use of such files
+# via sfre [probably as BUG/won't fix]
#
# Ultimate wishlist:
#
View
3 cli.HTML/COLLECT
@@ -582,7 +582,8 @@ COLLECT -v -toc -skip BOOK -auto index.html toc.html $(cat BOOKTOC) *.html *.pdf
firefox BOOK.html
# non-COLLECT version for chm / extracting chm: chm2pdf
-# (also: chmsee, cs2w, chm_http, xchm/gnochm/chmsee/kchmviewer; generation is windows/prop only)
+# (also: cs2w/chm_http(extract), xchm/gnochm/chmsee/kchmviewer; generation is windows/prop only)
+# firefox hates imagefile;ID img sources and strips ;ID on fs access - consider hardlinks
chm2pdf --continuous x.chm
chm2pdf --webpage --size=a4 x.chm
View
4 cli.conf/dir.mc/ini
@@ -76,7 +76,7 @@ editor_backup_extension=~
[Layout]
equal_split=1
-first_panel_size=56
+first_panel_size=79
message_visible=1
keybar_visible=1
xterm_title=1
@@ -88,7 +88,7 @@ permission_mode=0
filetype_mode=1
[Dirs]
-other_dir=/disk-CLS/IN/MANGA/TO_SORT/manga/IN/0KEEP/omamori_himari
+other_dir=/disk-CLS/media/audio/music/anime/albums/IN/DONE
current_is_left=0
[New Left Panel]
View
32 cli.firefox/00_FIREFOX.phtml
@@ -13,12 +13,32 @@ number of bookmarkfolders (have firefox or firefoxstdin invoke
firefoxgrep...) . In a pinch, the scripts below also offer a low level
method to diff/copy a few changed bookmarks.<p>
-<p>Note that the firefox wrapper should be rewritten in perl with
-firefoxstdin folded into the code. Currently thee two scripts call
-each other for a number of functions... . Thus I see the scripts (with
-the possible exception of firefoxgrep* itself) not as a released set
-of scripts, but more of a working example on accessing/grepping
-bookmarks and interacting with firefox from the the command line.</p>
+<p>As I'm using the command line rather than just mouse &amp; GUI,
+these scripts are life-safers and necessary to make firefox
+<i>properly</i> usable for me at a mere 'works-for-me' level. As such,
+this set of scripts is more of a raw concept example for firefox shell
+integration rather than a proper finished releasable script. That
+said, if you've a shell related firefox pet-peave, I'll gladly have a
+look at it :).</p>
+
+<p class=anno>See also: For a better generic approach to control
+firefox, consider e.g. perl-javascript bridging code like the <a
+href="http://search.cpan.org/search?query=mozrepl">Perl Interface to
+MozRepl</a> (<a href="http://wiki.github.com/bard/mozrepl/">MozRepl
+itself</a>), Corion's recent <a
+href="http://cpan.uwinnipeg.ca/dist/WWW-Mechanize-Firefox">WWW::Mechanize::Firefox</a>
+(should allow hacking a javascript-conscious wget-clone), or e.g. <a
+href="http://search.cpan.org/search?query=selenium">Selenium</a>.</p>
+
+<p class=anno>To use a tk-style approach to build a
+javascript-DOM-style user interface for a server script, consider e.g.
+XUL::Node.</p>
+
+<p class=anno>Note that the firefox wrapper should be rewritten in
+perl with firefoxstdin folded into the code. Currently the two scripts
+call each other for a number of functions... . But that's what you get
+with works-for-me examples :). </p>
+
<p>Some remarks:</p>
View
2 cli.firefox/00_FIREFOX.phtml.name
@@ -1 +1 @@
-a firefox wrapper / accessing bookmarks from the cli
+a firefox wrapper / improving usability of firefox from the command line incl. bookmark access (grepping url/description/tags)
View
53 cli.firefox/firefox
@@ -55,9 +55,22 @@
# options for its original behaviour, and implement the
# functionality of the firefox bash script, maybe with
# a new -grep option thrown in.
+#
+# - user, display, profile setting options in addition to -sm/-3
+# (note that multiple users' firefoxes on the same display
+# may not work, possibly requiring redirecting the
+# display of further instances to e.g. VNC
+# (at least for the same user/uid from multiple
+# machines to run on the same display))
# notes
+# - a better replacement might be replacing this set of scripts
+# by basing things around a MozRepl-enabled fine-grained-remote controlable
+# firefox (http://wiki.github.com/bard/mozrepl/)
+# (say using Corion's WWW::Mechanize::Firefox Perl Module as a base)
+# or at least considering File::Mork or Mozilla:: for more robust
+# profile guessing/parsing
# - using multiple profiles at once in a single user:
# - start the instance in the foreground by
# firefox -P test -no-remote URLs # or export MOZ_NO_REMOTE=1
@@ -125,8 +138,8 @@ echo "#START $f -no-remote ${1:+$@}"
# restart the command in case of some strange async X problem
echo "#TRY $f --sync -noraise -remote 'openURL($1,new-tab)'"
# and another thank-you to NVIDIA
- $f --sync -noraise -remote "openURL($1,new-tab)" 2> >(grep -v 'Xlib: extension "RANDR" missing on display') ||\
- { _sleep 2;_ping $f && $f --sync -noraise -remote "openURL($1,new-tab)" ;}||\
+ $f --sync -noraise -remote "openURL($1,new-tab)" 2> >(grep -v -e 'Xlib: *extension "RANDR" missing' -e 'GLib-WARNING.* g_set_prgname' -e '^ *$') ||\
+ { _sleep 2;_ping $f && $f --sync -noraise -remote "openURL($1,new-tab)" 2> >(grep -v -e 'Xlib: *extension "RANDR" missing' -e 'GLib-WARNING.* g_set_prgname' -e '^ *$') ;}||\
echo "#FAILED"
_sleep 1
else
@@ -175,7 +188,7 @@ function _ping {
function _ping2 {
# gee thanx, for nice and uptodate regular driver updates, NVIDIA. NOT.
# set -o pipefail
- "$1" --sync -remote "ping()" >/dev/null 2>&1 # 2>&1 | grep -v 'Xlib: *extension "RANDR" missing'
+ "$1" --sync -remote "ping()" >/dev/null 2> >(grep -v -e 'Xlib: *extension "RANDR" missing' -e 'GLib-WARNING.* g_set_prgname' -e '^ *$')
}
function _decode {
@@ -230,15 +243,24 @@ function _browsefile {
+export pre_opt noexec
while [ "$1" != "" ]; do
case "$1" in
+ # should go first...
-n|-no-exec) shift; noexec="-n"; f="/bin/echo No-Exec"; t=$f ;;
-3) f=$f3; pre_opt="-3 $pre_opt"; shift ;;
-sm|-sea|-seamonkey) f=$fs; pre_opt="-sm $pre_opt"; shift
firefox_to_start=1
ps -u `whoami` | egrep -e seamonkey-bin -e seamonkey > /dev/null && firefox_to_start=0
;;
+
+ # exit with suitable test status code
+ -procall) ps -ef | egrep -v egrep | egrep -e 'firefox*/firefox' -e thunderbird -e firefox-bin -e 'firefox.*-bin' -e mozilla; exit $? ;;
+ -proc) firefoxversion=${f##*-}; ps -ef | egrep -v egrep | grep "firefox-$firefoxversion/firefox"; exit $? ;;
+ -kill) firefoxversion=${f##*-}; $kill "firefox-$firefoxversion/firefox"; exit $? ;;
+ -ping) $f -remote "ping()"; exit $? ;;
+ -ping-tb) $t -remote "ping()"; exit $? ;;
# consider these to begin the list of urls [being handled in _browsefile]
-mail|-news) break ;;
@@ -250,11 +272,11 @@ while [ "$1" != "" ]; do
# firefoxgrep -i -w -U -k "$1" "$2" | firefoxstdin; shift; shift ;;
-k|-kw|-key|-keyword) shift;
[ "$pre_opt" = "" ] && firefoxstdin $noexec -key "$1" "$2" || \
- firefoxstdin -n -key "$1" "$2" | firefoxstdin $pre_opt $noexec /dev/stdin
+ firefoxstdin -n -key "$1" "$2" | firefoxstdin $noexec $pre_opt /dev/stdin
shift; shift ;;
-grep) shift;
[ "$pre_opt" = "" ] && firefoxstdin $pre_opt $noexec -grep "$1" || \
- firefoxstdin -n -grep "$1" | firefoxstdin $pre_opt $noexec /dev/stdin
+ firefoxstdin -n -grep "$1" | firefoxstdin $noexec $pre_opt /dev/stdin
shift ;; # use ::$1:: to match full fields when grepping
@@ -264,21 +286,16 @@ while [ "$1" != "" ]; do
-|stdin|STDIN|-stdin|-STDIN) shift; exec firefoxstdin ${1:+"$@"} ;;
# add your shortcut args below -- case patterns do not expand vars :(
- -example|-daily|-weekly|-nightly|-monthly*|-news.daily|-jobs.daily|-job.daily)
+ -example|-daily|-weekly|-nightly|-monthly*|-news.daily|-jobs.daily|-job.daily|-job.nightly|-jobs.nightly)
tmp="$0.$1";
- if [ -f "$tmp" ]; then
- cat "$tmp" | firefoxstdin $pre_opt
- else
- [ "$pre_opt" = "" ] && firefoxstdin "$1" || \
- firefoxstdin -n "$1" | firefoxstdin $pre_opt /dev/stdin
+ if [ -x "$tmp" ]; then # execute if -x
+ "$tmp"
+ elif [ -f "$tmp" ]; then # treat as input for firefoxstdin (incl. its GREP commands, etc)
+ cat "$tmp" | firefoxstdin $noexec $pre_opt
+ else # otherwise assume its a firefoxstdin option
+ [ "$pre_opt" = "" ] && firefoxstdin $noexec "$1" || \
+ firefoxstdin -n "$1" | firefoxstdin $noexec $pre_opt /dev/stdin
fi; shift ;;
-
- # exit with suitable test status code
- -procall) ps -ef | egrep -v egrep | egrep -e 'firefox*/firefox' -e thunderbird -e firefox-bin -e 'firefox.*-bin' -e mozilla; exit $? ;;
- -proc) firefoxversion=${f##*-}; ps -ef | egrep -v egrep | grep "firefox-$firefoxversion/firefox"; exit $? ;;
- -kill) firefoxversion=${f##*-}; $kill "firefox-$firefoxversion/firefox"; exit $? ;;
- -ping) $f -remote "ping()"; exit $? ;;
- -ping-tb) $t -remote "ping()"; exit $? ;;
-*) exec $f "${1:+$@}" ;; # firefox options
+*) exec $f "${1:+$@}" ;; # firefox options
View
2 cli.firefox/firefoxgrep
@@ -32,6 +32,8 @@
# not that we use much of it beyond dumping the tables into memory
# and then mangling them using hash-keys [instead of proper
# object refs]
+# - a more proper way to access might be e.g. looking into
+# File::Mork or Mozilla::Backup
use strict;
use vars;
View
11 cli.list.rename/emv
@@ -40,6 +40,8 @@ my $version="2.00pj.4";
# - none known.
#
# bugs and issues:
+# - miscounts on embedded newlines. WONT FIX.
+# (consider e.g. myrename 's/\n/ /g' on the culprits)
# - does NOT report non-conforming lines as IGNORED [won't fix for now]
# - while basic dir tracking is implemented, it still lacks true canonical
# de-linked dev/inode# name+path smashing. [won't fix for now]
@@ -717,7 +719,14 @@ sub getfiles {
}
}
push @orgfile,qx(find . -type d|emvs -r) if $o_dirtree;
- &cleanexit(1) if not @orgfile;
+
+ do{ print "No existing files to rename - exiting.\n"; &cleanexit(1)} if not @orgfile;
+ # this happens e.g. with emv FOO*, when the shell doesn't have any matches and
+ # provides FOO* as non-existing file arg to emv, resulting in an empty @orgfile
+ # due to the (arguably inefficient early) -e stat above. Note that emv itself
+ # with no args is a different case, running the find command for $PWD.
+ #
+ # Note: Use emv . to force a (near) empty session for just using concenience commands.
@orgfile=grep({s!/?\n?\z!!;1} @orgfile); # chomp and strip any trailing /
View
2 cli.processes/waitcond
@@ -241,7 +241,7 @@ sub grep_file {
# allow use of perl idiomatic 'command |' filenames
# this block temporarily uses shell rc semantics
$rc=0; # shell.true
- open(FH,$file) and defined read(FH,$tmp,$grepmaxsize,0) and close FH or $rc=256; # INTIONALLY INSECURE OPEN2
+ open(FH,$file) and defined read(FH,$tmp,$grepmaxsize,0) and close FH or $rc=256; # INTENTIONALLY INSECURE OPEN2 (IS SECURE)
$rc=$?>>8 if $?;
warn "# $Me: failed open/read for pipe grep $expr $file\n" if $rc and $rc==256;
warn "# $Me: rc for pipe grep $expr $file: $rc\n" if $rc and $rc!=256 and $verbose;
View
8 cli.processes/zap
@@ -134,6 +134,14 @@ Examples:
zap -l -y '^\\S+ +\\d+ +1 +' # list orphaned processes
zap -l -y -a '^(?!.*00:0\\d:\\d\\d)' # list cpu hogs (perl5 only)
+ # STOP & CONT vs job-control
+ bash -c 'cmd1; cmd2' # zap -STOP cmd1 pauses cmd1 and the list
+ bash$ ( cmd1; cmd2 ) # the same happens for subshells
+ bash$ cmd1; cmd2 # !! here bash job control instead suspends cmd1
+ bash$ { cmd1; cmd2; } # !! and cmd2 runs immediately. This also happens
+ # with the normal job-control ^z for both lists and
+ # { group commands; }.
+
# pipe dreams
echo UNUSED | echo `zap -l -a -C bash </dev/tty | nl`
zap -l -y bash 2>&1 | nl
View
1 cli.shell.functions/dir.shell/auth.func
@@ -11,6 +11,7 @@ GPG_TTY=`tty` # probably /proc/self/fd/0 - 2
[ -f ~/.gnupg/env.$HOSTNAME ] && . ~/.gnupg/env.$HOSTNAME 2>/dev/null
[ -f ~/.gnupg/gpg-agent-info-$HOSTNAME ] && . ~/.gnupg/gpg-agent-info-$HOSTNAME 2>/dev/null
+#echo $GPG_AGENT_INFO
if [ "$SSH_AUTH_SOCK" != "" ]; then
if test $SSH_AUTH_SOCK -nt ~/.ssh/env.$HOSTNAME; then
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK;export SSH_AUTH_SOCK > ~/.ssh/env.$HOSTNAME
View
24 cli.shell.functions/dir.shell/dict.func
@@ -23,11 +23,29 @@ function xlatej { # japanese/english
perl -e 'undef $/; $_=<STDIN>; $_="" if /Roman?ji Conversion Error|No Matches Found/i; s/\A[\s\S]*?Found//mgoi; s/ *_____[\s\S]*//mgoi; print' | grep .
true
}
-function xlatej2 { # japanese/english phrase translation via google, w3m for it's utf8 support (lynx doesn't, but that might be google's http headers)
- w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&sl=ja&tl=en&text="`perl -e 'print join "%20", @ARGV;' "$@"` |\
+function xl_isascii {
+ perl -e '$_=join(" ",@ARGV); $_=`cat /dev/stdin` if $_ eq "-"; print; exit 1 if /[^\s\x20-\x7e]/' ${1:-"$@"}
+}
+function xl_isgerman { xl_islatin ;}
+function xl_islatin1 { xl_islatin ;} # a lie -- of course, it's UTF8, not latin1
+function xl_islatin {
+ perl -e '$_=join(" ",@ARGV); $_=`cat /dev/stdin` if $_ eq "-"; print; s/[\xc3\xc4][\x80-\xbf]//g; exit 1 if /[^\s\x20-\x7e]/' ${1:-"$@"}
+}
+function xlatej2 { # japanese/english phrase+romaji translation via google
+ # using w3m for it's utf8 support (lynx doesn't work regardless of -assume*, but that might be google's http headers)
+ # - a local romaji conversion would be e.g.
+ # echo 当世ロマン歌集 | iconv -f utf-8 -t euc-jp | kakasi -Ha -Ka -Ja -Ea -ka -C -s # | iconv -f euc-jp -t utf-8
+ # H, K, J, E, k are the conversion options, C is capitalization, s keeps space
+ # the iconv is required, as ancient kakasi still doesn't know about utf8
+ # - recode doesn't seem to handle smashing to romaji at all (recode: use -f to FORCE even on translation problems of input...)
+ # - see also: http://php.net/manual/en/function.recode-string.php (e.g. romaji to hiragana transliteration)
+ # - detecting non-ascii/non-sane: perl -lne 'exit 1 if not /[^\x20-\x7e]/' # maybe allow for CRLF and TAB or even ESC/CSI
+ # - DEC, EUC, SJIS are older non-compatible kanji encodings
+ arg="$(perl -e '$_=join " ", @ARGV; s/([\(\)\[\]\{\}\&\;\+\s])/"%".unpack(H2,$1)/geo; print' "$@")"
+ w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&sl=ja&tl=en&text=$arg" |\
perl -e 'undef $/; $_=<STDIN>; /[\s\S]+?Japanese to English.*\n([\S\s]*?)\n.*contribute a better translation/i and $_=$1 or $_=""; print' | grep .
echo
- w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&tl=ja&sl=en&text="`perl -e 'print join "%20", @ARGV;' "$@"` |\
+ w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&tl=ja&sl=en&text=$arg" |\
perl -e 'undef $/; $_=<STDIN>; /[\s\S]+?English to Japanese.*\n([\S\s]*?)\n.*contribute a better translation/i and $_=$1 or $_=""; print' | grep .
true
}
View
50 cli.shell.functions/dir.shell/grep.func
@@ -32,21 +32,35 @@ function gr_x {
function gr_H { gr_HELP; }
function gr_HELP {
cat <<EOF
- gr_* family of filename filters (uniq/unsort implied except gr_S):
+ # gr_* family of filename filters (all retain original ordering):
gr_H, gr_HELP
- gr_U, gr_UNIQ -- uniq but not sort input
- gr_S, gr_STRIP -- strip ' :: '-comments from input (e.g. ogg tags, etc)
- gr_D, gr_DIR -- truncate to basedir
- gr_F, gr_FILE -- existing plain files (implies strip/uniq)
- gr_D0 -- magical truncate to basedir/filename
- gr_DS -- magical paren removal + ~~-shorten for long filenames
+ gr_U, gr_UNIQ -- uniq
+ gr_S, gr_STRIP -- strip ' :: '-comments from input (e.g. '<filename> :: <ogg tags>+')
+ gr_D, gr_BASEDIR -- truncate to basedir (implies uniq)
+
+ # filter accesses fs (implies stat/strip/uniq; allows for files containing ' :: '):
+ gr_STRIP0 -- only existing in fs (strict superset of gr_STAT[FD])
+ gr_STATF -- only plain files
+ gr_STATD -- only existing dir/symlink to existing dir
+ gr_BASEDIR0 -- truncate plain files to basedir, but keep dirs as is
+
+ # reporting only (implies uniq; output is no longer a list of filenames):
+ # BUG: should honor COLUMNS to specify what to cut
+ gr_SHORT -- magical truncate to basedir/filename
+ gr_SHORT0 -- magical paren removal + ~~-shorten for long filenames
+
EOF
}
# gr_* family of filters for handling reporting lists of files (changed to uniq/unsort, caches all seen entries)
-function gr_F { gr_FILE; }
-function gr_FILE {
+function gr_STRIP0 {
+ perl -lne 'next if $c{$_}; do{print;$c{$_}++;next} if -e $_; s/ :: +(\S.*|)?$// and do{next if $c{$_};do{print;$c{$_}++;next} if -e $_};'
+}
+function gr_STATF {
perl -lne 'next if $c{$_}; do{print;$c{$_}++;next} if -f $_; s/ :: +(\S.*|)?$// and do{next if $c{$_};do{print;$c{$_}++;next} if -f $_};'
}
+function gr_STATD {
+ perl -lne 'next if $c{$_}; do{print;$c{$_}++;next} if -d $_; s/ :: +(\S.*|)?$// and do{next if $c{$_};do{print;$c{$_}++;next} if -d $_};'
+}
function gr_S { gr_STRIP; }
function gr_STRIP {
perl -lne 's/ :: +(\S.*|)?$//; print' # no uniq for this
@@ -55,19 +69,23 @@ function gr_U { gr_UNIQ; }
function gr_UNIQ {
perl -lne 'print if not $c{$_}++'
}
-function gr_D { gr_DIR; }
-function gr_DIR {
- perl -lne 's@/[^/]*$@@; print if not $c{$_}++' # uniq, but unsorted
+function gr_D { gr_BASEDIR; }
+function gr_BASEDIR { # note that this can easily strip the matched keyword from the filename
+ perl -lne 's@/[^/]*$@@ if not m!/(MNG|LNK)\.[^/]+$|/[^/]*\.lnk!; print if not $c{$_}++' # uniq, but unsorted, don't strip .lnk (hopefully a symlink)
# sed 's@/[^/]*$@@' | sort -u or just in sed (uniq w/o sort): sed 's@/[^/]*$@@'|sed '$!N; /^\(.*\)\n\1$/!P; D'
}
-function gr_D0 { gr_DIR0;}
-function gr_DIR0 {
+function gr_BASEDIR0 { #
+ perl -lne 'next if $c{$_}; do{print;$c{$_}++;next} if -d $_;
+ s/ :: +(\S.*|)?$// if not -e _;
+ next if $c{$_}; do{print;$c{$_}++;next} if -d $_;
+ s@/[^/]*$@@ if not m!/(MNG|LNK)\.[^/]+$|/[^/]*\.lnk!; print if not $c{$_}++'
+}
+function gr_SHORT {
# shorten to the final dir/filename with a twist:
# go further left while dir is numbered, i.e. \d* c\d* v\d*
perl -lne '"SECURE:OK";BEGIN {s!^(\s)!./$1!,s/^/</,s/$/\0/ for @ARGV}; s@.*?(((/|^)(?!\d|[vc]\d)[^/]+)(/(?=\d|.\d)[^/]+)*/[^/]+)$@...$1@i; print if not $c{$_}++'
}
-function gr_DS { gr_DIRSHORTEN;}
-function gr_DIRSHORTEN {
+function gr_SHORT0 {
# shorten by paren+ removal to a single ~~, then if there's still a monstrous name
# in the path, truncate it in the middle. Use $1 to change 'longness'.
# tries to allow for the highlighting codes as used on xterm by tput rmso/smso
View
37 cli.shell.functions/dir.shell/misc.func
@@ -3,12 +3,49 @@
# archive: http://jakobi.github.com/script-archive-doc/
alias psg='ps -efww | grep -i'
+alias wget0='wget --retry-connrefused --limit-rate=500k --waitretry=10 --wait=3 --random-wait'
if [ -n "_IS_BASH" ]; then
# ksh interpretes '.' as marker for discipline functions
function ls_size { # user needs to add -d as required
ls -1 -al ${1:+"$@"} | sort -nbk5
}
+
+ # history NOTES
+
+ # a) global bash history
+ # by default: replace history with session's history list ON CLOSE
+ # (for ksh global history may even be the default; consider just $$
+ # or better the pty number as part of the history file to avoid if
+ # necessary)
+ # 1. shopt -s histappend # (done on close; however truncated thus still
+ # lossy when ending long sessions; to avoid:)
+ # 2. PROMPT_COMMAND='history -a' # (whenever displaying the prompt,
+ # write the previous line to disk:
+ # but this may disorient due to mixing history
+ # and may be rather interesting in those
+ # to-be-frowned-upon-multi-root situations...)
+
+ # b) example for readline usage in loops, with retaining
+ # BOTH the history entry for the loop command (history_self)
+ # AND the user's readline input in the history list (history -s):
+ # $ history_self; while read -ep ">> "; do history -s "$REPLY"; gr_x $REPLY; done
+ # BUG1: history -r <(...) # appending works only with plain files!?
+ # BUG2: the first history -s statement in an manually entered shell command
+ # line kills the line's history entry (may actually be
+ # version-depending bug). Further history -s properly append.
+ # So the next function basically is an idempotent NOP wasting
+ # the first history -s. Otherwise it's highly annoying to loose
+ # the loop entry from the history and having to reenter a complex
+ # command needlessly.
+ function history_self {
+ # "NOP" - avoids loosing the current history line when
+ # explicitly appending with history -s
+ # history -s "$(history 1|sed -r 's/ *[0-9]+ +//')";
+ typeset _last="$(history 1)"
+ history -s "${_last/#*( )+([0-9])+( )/}"
+ }
+
fi
export EMVSHELL=/bin/bash
View
7 cli.various/dir.printing/lpr
@@ -6,7 +6,11 @@
{ set; echo $$ is own pid; ps -ef; } > $HOME/.lpr.debug
-if echo "$ADDON_PATH" | grep -i firefox >/dev/null ||
+echo "$*" 2>&1
+
+if echo "$*" | egrep -e '^-P ?PDF$' >/dev/null; then
+ /usr/bin/lpr "$@"
+else if echo "$ADDON_PATH" | grep -i firefox >/dev/null ||
set | grep -e MOZ_LAUNCHED_CHILD -e 'MYPSNUPREROUTEALL' >/dev/null ||
test -f $HOME/.mypsnuprerouteall && [ "$MYSPNUPSKIPREROUTEALL" = "" ] ; then
opt=${MYPSNUPREROUTEOPT:--2}
@@ -21,6 +25,7 @@ if echo "$ADDON_PATH" | grep -i firefox >/dev/null ||
else
/usr/bin/lpr "$@"
fi
+fi
# MOZILLA CUM GNOME IDIOCY PRINTING WORKAROUND
View
9 cli.various/dir.printing/myenscript
@@ -13,13 +13,15 @@ MYENSCRIPTPRT=${MYENSCRIPTPRT:-$PRINTER}
[ "$MYLPROPT" = "" ] && MYLPROPT="" # -l
MYENSCRIPT=enscript
MYA2PS=a2ps
+job=""
CMD=$MYENSCRIPT
loop=1; while [ "$1" != "" -a "$loop" ]; do
case "$1" in
-P|-d) MYENSCRIPTPRT=$2; shift ;;
-P*) MYENSCRIPTPRT=${1##-P} ;;
-d*) MYENSCRIPTPRT=${1##-d} ;;
+ -J|-C|-T) job="$2"; shift ;;
-8) MYENSCRIPTFMT="-1 --nup 8 --portrait -L 72" ;; # -fCourier7"
-4) MYENSCRIPTFMT="-1 --nup 4 --portrait -L 72 -fCourier9" ;;
-4w) MYENSCRIPTFMT="-1 --nup 4 --portrait -L 90 -fCourier7" ;;
@@ -44,9 +46,12 @@ default=""; test "$1" = "" && default=/dev/stdin
for i in $default "$@"; do
test "$i" = "" && continue
+ # job is the job title
+ # missing: smash UTF-8 if any, add unique-mid-fix (but that's better done by Label=1 in /etc/cups/cups-pdf.conf)
+ job1="$i"; test "$job" != "" && job1="$job"
echo "using $CMD with printer $MYENSCRIPTPRT";
case $CMD in
- *enscript*) $MYENSCRIPT $MYENSCRIPTFMT $MYENSCRIPTOPT -G --mark-wrapped-lines=arrow -MA4dj --pass-through -p - "$i" | mypsnup -1 -P$MYENSCRIPTPRT ;;
+ *enscript*) $MYENSCRIPT $MYENSCRIPTFMT $MYENSCRIPTOPT -G --mark-wrapped-lines=arrow -MA4dj --pass-through -p - "$i" | mypsnup -1 -P$MYENSCRIPTPRT -J "$job1";;
*a2ps*)
# a2ps and manpage differ regarding -f and -n, -nP, --center-title, ...
# at least folding is still implicit default
@@ -56,7 +61,7 @@ for i in $default "$@"; do
# protect perl against insecure magic <> idiocy
cat "$i" | \
perl -e 'while(<>){s/([^\x8\x9\xA\xC\x20-\x7E\xA0-\xFF])/"&#0x".unpack(H2,$1).";"/ge; print}' | \
- $MYA2PS "--center-title=$i" $MYENSCRIPTFMT $MYA2PSOPT -b -o - | mypsnup -1 -P$MYENSCRIPTPRT ;;
+ $MYA2PS "--center-title=$job1" $MYENSCRIPTFMT $MYA2PSOPT -b -o - | mypsnup -1 -P$MYENSCRIPTPRT -J "$job1";;
*) $CMD ;;
esac
done
View
13 cli.various/dir.printing/mypsnup
@@ -36,6 +36,7 @@ $MYPSNUPFMT=-1 if not $MYPSNUPFMT and $0!~/up/;
$MYPSNUPFMT=-4 if not $MYPSNUPFMT;
$MYPSNUPOPT=$ENV{$MYPSNUPOPT};
$MYLPROPT =$ENV{$MYLPROPT};
+$job="";
while(@ARGV) {
$_=$ARGV[0];
@@ -47,6 +48,7 @@ while(@ARGV) {
# however if acroread, first turn off let printer determine colors + lv3,
# then consider trying 'print as image' (q: resolution or is that some kind of vectorized gfx stream format??)
# font-DL could also create silent ps memory-issues
+ /^-[CJT]$/ and do{$job.=qq! $_!; $_=$ARGV[1]; s/[^\x20-\x7e]/./g; s/["']/./g;; $job.=qq! "$_"!; shift; shift; next}; # job title
last;
}
$ARGV[0]="/dev/stdin" if "-" eq $ARGV[0];
@@ -71,6 +73,8 @@ $MYPSNUPPRT = "lj" if $MYPSNUPPRT =~ /^lj$/;
if ($MYPSNUPPRT=~/@/) {
$lpr="lprng";
+} else {
+ $lpr="/usr/bin/lpr";
}
$lpr="$lpr -P$MYPSNUPPRT $MYLPROPT $RAW";
@@ -81,9 +85,12 @@ foreach (@ARGV) {
next if not /\S/;
print main::STDERR "mypsnup: printing $_\n";
s/'/\\'/g;
- $ENV{file}=$_;
- print main::STDERR "mypsnup: ". "cat /dev/null \"$_\" | $psnup | $psselect | $gs | $lpr". "\n";
- system "cat /dev/null \"\$file\" | $psnup | $psselect | $gs | $lpr";
+ $job1=$ENV{file}=$_;
+ $job1=~s/[^\x20-\x7e]/./g; $job1=~s/["']/./g;
+ $job1=qq!-J "$job1"!;
+ $job1=$job if $job;
+ print main::STDERR "mypsnup: ". "cat /dev/null \"$_\" | $psnup | $psselect | $gs | $lpr $job1". "\n";
+ system "cat /dev/null \"\$file\" | $psnup | $psselect | $gs | $lpr $job1";
if ($?) {
print "# lpr err -- in case of wrong printer name, use eg: export MYPSNUPPRT=lj\@kefk.compact\n"
}

0 comments on commit 89c8619

Please sign in to comment.