####### # # E-scripts on the Z shell. # # Note 1: use the eev command (defined in eev.el) and the # ee alias (in my .zshrc) to execute parts of this file. # Executing this file as a whole makes no sense. # # Note 2: be VERY careful and make sure you understand what # you're doing. # # Note 3: If you use a shell other than zsh things like |& # and the for loops may not work. # # Note 4: I always run as root. # # Note 5: some parts are too old and don't work anymore. Some # never worked. # # Note 6: the definitions for the find-xxxfile commands are on my # .emacs. # # Note 7: if you see a strange command check my .zshrc -- it may # be defined there as a function or an alias. # # Note 8: the sections without dates are always older than the # sections with dates. # # This file is at # or at . # See also , # , # , # , # and . # ####### # «.zsh-beta» (to "zsh-beta") # «.zsh-hurd» (to "zsh-hurd") # «.zsh-files» (to "zsh-files") # «.zsh_help» (to "zsh_help") # «.heredoc» (to "heredoc") # «.zsh_suid» (to "zsh_suid") # «.bindkey_bug» (to "bindkey_bug") # «.strange_arguments» (to "strange_arguments") # «.prompt» (to "prompt") # «.zcatinfo» (to "zcatinfo") # «.unsetall» (to "unsetall") # «.compctl_defaults» (to "compctl_defaults") # «.completion-sudo» (to "completion-sudo") # «.aliases-in--c» (to "aliases-in--c") # «.foreachline» (to "foreachline") # «.zshrc-hash-bang-eval» (to "zshrc-hash-bang-eval") ##### # # Compiling zsh in the Hurd # ##### psnedeb <<'---' 143332 dists/potato/main/source/shells/zsh30_3.0.7-4.diff.gz 682 dists/potato/main/source/shells/zsh30_3.0.7-4.dsc 650042 dists/potato/main/source/shells/zsh30_3.0.7.orig.tar.gz --- pdsc $SDEBIAN/dists/potato/main/source/shells/zsh30_3.0.7-4.dsc rm -Rv /gnu/usr/src/zsh30-3.0.7 cp -diPpvR /usr/src/zsh30-3.0.7 /gnu/ # Oops, seems that this zsh hasn't been ported to the Hurd yet! # Trying again with a newer version. ##### # # zsh-beta (woody) # 2000oct18 # ##### # «zsh-beta» (to ".zsh-beta") # pdsc $SDEBIAN/dists/woody/main/source/shells/zsh-beta_3.1.9.dev6.0sf20001010-1.dsc cd /usr/src/ tar -cvzf zshbetasrc.tgz zsh-beta-3.1.9.dev6.0sf20001010/ cd /usr/src/zsh-beta-3.1.9.dev6.0sf20001010/ debian/rules binary |& tee odrb # dpkg -i /usr/src/zsh-beta*.deb # (find-status "zsh-beta") # (find-vldifile "zsh-beta.list") # (find-fline "/usr/doc/zsh-beta/") # (find-status "zsh-beta-doc") # (find-vldifile "zsh-beta-doc.list") # (find-fline "/usr/doc/zsh-beta-doc/") # «zsh-hurd» (to ".zsh-hurd") # (code-c-d "zshbeta" "/usr/src/zsh-beta-3.1.9.dev6.0sf20001010/") # (find-zshbetafile "") # (find-zshbetafile "odrb") # (find-zshbetafile "debian/control" "Build-Depends" # (find-zshbetafile "ChangeLog-Release" "hurd") # cd /usr/src mount -o remount,rw /gnu cp /usr/src/zshbetasrc.tgz /gnu/usr/src/ # ##### # # zsh startup/shutdown files # 2000jun22 # ##### # «zsh-files» (to ".zsh-files") # (find-node "(zsh)Files") # (find-fline "/etc/zshenv") # (find-fline "/etc/zprofile") # (find-fline "/etc/zshrc") # (find-fline "/etc/zlogin") # (find-fline "/etc/zlogout") # (find-fline "/etc/zsh30/zshenv") # (find-fline "/etc/zsh30/zprofile") # (find-fline "/etc/zsh30/zshrc") # (find-fline "/etc/zsh30/zlogout") ##### # # zsh 3.1.4 # (old notes) # ##### cd /usr/src/ rm -Rv zsh-3.1.4/ tar -xvzf /snarf/ftp/ftp.zsh.org/pub/zsh-3.1.4.tar.gz cd /usr/src/zsh-3.1.4/ ./configure |& tee oc make |& tee om make prefix=/usr install |& tee omi cd /usr/src/zsh-3.1.4/ etags $(find * -name '*.[ch]') cp -v /usr/src/zsh-3.1.4/Doc/zsh.info* /usr/info/ rm -v /usr/info/zsh*gz cd /bin/ [ -f zsh-3.0.2 ] || mv -iv zsh zsh-3.0.2 ln /usr/bin/zsh . cd /snarf/http/www.ifh.de/~pws/computing/zsh_fns/ agrep zle * # (find-zshnode "Top") # (find-zshnode "Command Substitution") # (find-zshnode "Editor Functions Index") # (find-zshnode "Shell Builtin Commands") # (find-zshnode "Completion") # (find-zshnode "Zsh Line Editor" "User-Defined Widgets\n") # (find-zshnode "Concept Index" "* widgets") # (find-zshnode "The zle Module" "`zle' `-N'") # (find-fline "/usr/src/zsh-3.1.4/Makefile") # (find-zshfile "Src/Modules/example.c") # (find-zshfile "Src/Modules/example.mdd") # (find-zshfile "Src/Zle/iwidgets.list") # (find-zshfile "Functions/zed") # (find-zshfile "Src/builtin.c") # (find-zshtag "bin_print") function fooo() { echo a print -z 'Rum' } zle -N foo fooo bindkey "^[[[E" foo # (find-fline "/snarf/http/sunsite.auc.dk/zsh/FAQ/zshfaq.yo") # (find-fline "/snarf/http/sunsite.auc.dk/zsh/FAQ/zshfaq.yo" "label(44)") # Some examples: i=0 while [ $i -le 100000 ] do echo ':'$i':' i=$[$i+1024] done ###### # # zsh help # 1999sep?? # ###### # «zsh_help» (to ".zsh_help") # (find-fline "/usr/doc/zsh/") # (find-fline "/usr/doc/zsh/FEATURES") # (find-fline "/usr/doc/zsh/examples/Util/") # (find-fline "/usr/doc/zsh/examples/Util/helpfiles" "-h") # (find-angg ".zshrc" "run-help") # Only the "builtins" are covered, the ones in: # (find-zshnode "Shell Builtin Commands") cd ~ rm -Rv $ZSHHELPDIR mkdir $ZSHHELPDIR && cd $ZSHHELPDIR && { man zshbuiltins | colcrt - | perl /usr/doc/zsh/examples/Util/helpfiles } ##### # # zsh ref card # ##### xdvi -paper 30x21cm $S/http/www.ifh.de/~pws/computing/refcard.dvi & cd /tmp/ cp -v $S/http/www.ifh.de/~pws/computing/refcard.dvi . make -f ~/LATEX/Makefile refcard.ps refcard.zip ##### # # heredoc # ##### # «heredoc» (to ".heredoc") # (find-node "(zsh)Shell Builtin Commands" "`getopts") # (find-zshfile "Src/builtin.c" "to start a new option parse") # (find-fline "/usr/doc/zsh/examples/Functions/zls" "getopts") # (find-fline "~/.zshrc" "heredoc") heredoc /tmp/bar -o edrx:edrx -m 0333 <<'---' foo bar --- laf /tmp # This works but interacts badly with set +v/set -v: cat <<--- echo $SHELL --- ##### # # Running as other users # ##### # «zsh_suid» (to ".zsh_suid") # (find-node "(zsh)Parameters Set By The Shell" "EUID") # (find-node "(zsh)Parameters Set By The Shell" "USERNAME") # (find-node "(sh-utils)User information") # (find-fline "/etc/passwd") # (find-fline "/etc/groups") cat /etc/passwd /etc/groups | sort # (find-k2tag "sys_setgroups") # id id -g id -G id -u id -ng id -nu id -nG id -rg id -ru id -rG id -nrg id -nru id -nrG # (UID=$(id -u edrx); id) (EUID=$(id -u edrx); id) (UID=$(id -u edrx); EUID=$UID; id) (UID=$(id -u edrx); EUID=$UID; GID=$UID; id) (UID=$(id -u edrx); GID=$UID; EUID=$UID; id) (GID=$(id -u edrx); EUID=$GID; UID=$GID; id) (GID=$(id -u edrx); UID=$GID; EUID=$GID; id) # USERNAME=edrx id (USERNAME=edrx; id; echo $HOME) # ##### # # Recompiling zsh at twu # 99dec05 # ##### # (find-fline "$SDEBIAN/ls-lR.i") mkdir ~/dl cd ~/dl export FDEBIAN_UTK=ftp://ftp.sunsite.utk.edu/pub/linux/Debian export FDEBIAN=$FDEBIAN_UTK echo $FDEBIAN wget $FDEBIAN/dists/slink/main/source/shells/zsh_3.1.2-10.diff.gz wget $FDEBIAN/dists/slink/main/source/shells/zsh_3.1.2-10.dsc wget $FDEBIAN/dists/slink/main/source/shells/zsh_3.1.2.orig.tar.gz cd ~/dl/ 'rm' -R zsh-3.1.2 zsh-3.1.2.orig cd ~/dl tar -xvzf zsh_3.1.2.orig.tar.gz ln -s zsh-3.1.2 zsh-3.1.2.orig zcat zsh_3.1.2-10.diff.gz | patch -p0 2>&1 | tee op cd ~/dl/zsh-3.1.2/ ./configure 2>&1 | tee ../oc cd ~/dl/zsh-3.1.2/Src/ make 2>&1 | tee ../om cd ~/dl/zsh-3.1.2/Src/ cp -v zsh ~/bin/ # ifdef LOCAL # mkdir ~/dl cd /big/slinks2/dists/slink/main/source/shells/ cp -v zsh* ~/dl # # endif # Lixos: # (find-node "(bash)Redirections") # (find-node "(bash)Pipelines") cp -v /big/slinkb1/dists/slink/main/binary-i386/shells/zsh_3.1.2-10.deb ~/dl/ cd ~/dl/ # ar p zsh_3.1.2-10.deb data.tar.gz | tar -tvzf - ar p zsh_3.1.2-10.deb data.tar.gz | tar -xvzf - usr/bin/zsh mv -v usr/bin/zsh ~/bin/ cd ~/dl/ wget $FDEBIAN/dists/slink/main/binary-i386/shells/zsh_3.1.2-10.deb ar p zsh_3.1.2-10.deb data.tar.gz | tar -xvzf - usr/bin/zsh mv -v usr/bin/zsh ~/bin/ ##### # # bindkey bug in zsh-3.1.6 # 2000mar28 # ##### # «bindkey_bug» (to ".bindkey_bug") # (find-fline "/etc/passwd") # (find-fline "~/EXPECT/bindkey_bug") ln -sf ~root/EXPECT/bindkey_bug ~a/bkb ##### # # How to pass arguments with strange chars # 2000may18 # ##### # «strange_arguments» (to ".strange_arguments") # (find-zshfile "Src/exec.c" "here document ") cat > ~/o <<'---' foo bar wiki am --- echo "$(<~/o)" ##### # # prompt # 2000jun21 # ##### # «prompt» (to ".prompt") # (find-angg ".zshrc" "prompt") # (find-zshnode "Parameters Used By The Shell" "PS1") # (find-zshnode "Parameters Used By The Shell" "`PS1'" "`%n'") # (find-zshnode "Parameters Set By The Shell" "`USERNAME'") # (find-zshnode "Prompt Expansion") # First char of the name of the machine: uname -n export machine=$(uname -n) echo $machine[1] export PS1="%d(%n:$machine[1])# " echo $PS1 # (find-angg ".zshrc" "prompt") if [[ $machine = angg ]]; then export PS1='%d(%n)# ' else export PS1="%d(%n:$machine[1])# " fi # But %n is the username, not the effective username... # (find-angg ".zshrc.local.mcgill" "prompt") ##### # # More about globbing # 2000aug27 # ##### # «zcatinfo» (to ".zcatinfo") # (find-angg ".zshrc" "zcatinfo") # (find-node "(zsh)Filename Generation") # (find-node "(zsh)Description of Options" "\nNULL_GLOB") # cd /usr/share/info/ ls gdb* ls ipc* (setopt NULL_GLOB; zcat gdb.info{,-?,-??}.gz) |& l (setopt NULL_GLOB; zcat ipc.info{,-?,-??}.gz) |& l (setopt NULL_GLOB; zcat gdb{,.info}{,-?,-??}.gz) |& l (setopt NULL_GLOB; zcat ipc{,.info}{,-?,-??}.gz) |& l (unsetopt NULL_GLOB; zcat gdb.info{,-?,-??}.gz) |& l (unsetopt NULL_GLOB; zcat ipc.info{,-?,-??}.gz) |& l # # Note that zcatinfo as it is now will complain about not finding # xxx.info.gz or xxx.gz -- and we always have at most one of them, so # we always get a (harmless) error. # # (find-man "find") # (find-man "find" "-maxdepth levels") # (find-man "find" "-regex pattern") cd /usr/share/info/ ls gdb* ls ipc* (setopt NULL_GLOB; zcat gdb.info{,-?,-??}.gz) |& l # zcatinfo /usr/info/zsh > /tmp/zsh.info # (find-fline "/tmp/zsh.info") # ##### # # unsetall # 2000oct09 # ##### # «unsetall» (to ".unsetall") # (find-angg ".zshrc" "unsetall") # The test below needs to be run inside eeg because "unsetall" lives # in my .zshrc... an apparent alternative would be to run it directly # but within "()"s, but then we would get output only after the full # "()" block, not after each line, and the output would be very # difficult to interpret by lazy minds like mine. # cat > $EEG <<'---' set | wc unsetall set | wc set | wc _unsetall set | wc env exit --- # Now entering another zsh, with eeg; you should type a series of "M-l"s. eeg zsh # Done. # set | grep -a -v '=' set | awk -F '=' 'NF>1 {print $1}' # set | awk -F '=' 'NF>1 {print $1}' | grep '^[A-Z]' set | awk -F '=' 'NF>1 {print $1}' | grep -v '^[A-Z]' # # (find-node "(zsh)Process Substitution" "If =(...) is used") comm -2 -3 \ =(set | awk -F '=' 'NF>1 {print $1}' | grep '^[A-Z]') \ =(print -l ZSH_NAME ZSH_VERSION) # ##### # # compctl defaults # 2000oct09 # ##### # «compctl_defaults» (to ".compctl_defaults") # (find-angg ".zshrc" "completion") # "beth" is one of the accounts I use for tests; her home dir doesn't # have any zsh initialization files. # (find-es "mail" "test-pop3server") # cat > $EEG <<'---' echo zsh30 echo $ZSH_VERSION compctl compctl -L exit echo zsh echo $ZSH_VERSION compctl compctl -L exit exit --- eeg su - beth # ##### # # the default completion method for sudo # 2004sep07 # ##### # «completion-sudo» (to ".completion-sudo") # (find-status "zsh") # (find-vldifile "zsh.list") # (find-udfile "zsh/") # cd /var/lib/dpkg/info/ grep -l sudo $( /tmp/.zshrc zsh -c ". /tmp/.zshrc; alias w" zsh -c ". /tmp/.zshrc; /usr/bin/w w" zsh -c ". /tmp/.zshrc; which w" zsh -c ". /tmp/.zshrc; w w" zsh -c ". /tmp/.zshrc; enable -a; w w" zsh -c ". /tmp/.zshrc; enable -af > /dev/null; w w" zsh -c ". /tmp/.zshrc; function w () { which $* }; w w" # # how do I enable aliases in a "-c" block? # (...) # I can't make "w w" behave as "which w" # Here's what I'm trying to do... # (find-efunction 'shell-command-to-string) (defun zsh-command-to-string (command) (with-output-to-string (with-current-buffer standard-output (call-process "/usr/bin/zsh" nil t nil "-c" command)))) (defun zsh-do (command) (zsh-command-to-string (concat "TERM=nil . ~/.zshrc\n" command))) (zsh-command-to-string "TERM=nil . ~/.zshrc; enable -a > /dev/null\nw") (zsh-command-to-string "TERM=nil . ~/.zshrc\nw zsh") (zsh-command-to-string "TERM=nil . ~/.zshrc\n/usr/bin/w") (zsh-do "w") (zsh-do "/usr/bin/w") (zsh-do "alias w") (zsh-do "w") # (find-node "(zsh)Aliasing") ##### # # iterating over lines of a file # 2004oct02 # ##### # «foreachline» (to ".foreachline") # # (find-node "(zsh)Parameter Expansion" "If NAME is an array parameter") A=(foo bar plic ploc) print -l $A # # (find-node "(zsh)Parameter Expansion" "For example, ${(f)") cat > /tmp/o <<'%%%' aaa a b bbb b ccc ccc %%% for i in $( /tmp/linuxmine <<'%%%' # Reconstructed via infocmp from file: /etc/terminfo/l/linux # acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i\316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376, # (find-sh "infocmp linux") # linuxmine|linux console mine, am, bce, ccc, eo, mir, msgr, xenl, xon, colors#8, it#8, ncv#18, pairs#64, acsc=+>\,<-^.v0#`+a:f\\g#h#i#j+k+l+m+n+o~p-q-r-s_t+u+v+w+x|y{*|!}f~o, bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[?25l\E[?1c, clear=\E[H\E[J, cnorm=\E[?25h\E[?0c, cr=^M, csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=^J, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, cvvis=\E[?25h\E[?8c, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, flash=\E[?5h\E[?5l$<200/>, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=^J, initc=\E]P%p1%x%p2%{256}%*%{1000}%/%02x%p3%{256}%*%{1000}%/%02x%p4%{256}%*%{1000}%/%02x, invis=\E[8m, kb2=\E[G, kbs=\177, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, kend=\E[4~, kf1=\E[[A, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[[B, kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, kspd=^Z, nel=^M^J, oc=\E]R, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rmacs=\E[10m, rmir=\E[4l, rmpch=\E[10m, rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]R, sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, sgr0=\E[0;10m, smacs=\E[11m, smir=\E[4h, smpch=\E[11m, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?6c, u9=\E[c, vpa=\E[%i%p1%dd, %%% TERMINFO=/tmp/terminfo tic /tmp/linuxmine # (find-sh "TERMINFO=/tmp/terminfo infocmp linuxmine") cd /usr/share/doc/dialog/examples/ TERMINFO=/tmp/terminfo TERM=linuxmine ./menubox # # ok but this messed up with the background colors. # Discover how to make a terminfo entry inherit from another one. # # (find-node "(zsh)Shell Builtin Commands" "eval [ ARG ... ]") function foo () { printf "%-10s ;#-> %s\n" $1 "$(eval $1)" } set +v foo 'id' foo 'id -g' foo 'id -G' foo 'id -u' foo 'id -ng' foo 'id -nu' foo 'id -nG' foo 'id -rg' foo 'id -ru' foo 'id -rG' foo 'id -nrg' foo 'id -nru' foo 'id -nrG' # # Local Variables: # coding: no-conversion # ee-delimiter-hash: "\n#\n" # ee-delimiter-percent: "\n%\n" # ee-anchor-format: "«%s»" # End: