#! /bin/zsh -f # $Id: .zshrc-compctl,v 1.21 1996/06/13 20:59:45 gjb Exp $ # By Greg J. Badros (C) 1994-1996 # gjb@cs.duke.edu, http://www.cs.duke.edu/~gjb # Distribute freely as long as credit is given. # # You may use this file as specified under the GNU # public license (GPL). # I am not responsible for this file's use, misuse, or anything. # Use at your own risk. # # This file sets up some sophisticated completion control # under zsh 2.5.03. Be wary of v2.6 or better, as some of the # constructs have changed and broken these, I think # #setopt COMPLETE_ALIASES #Precompute hostnames # if not on NIS+, should set NONIS=true in /etc/env ifdef([[[[NIS]]]],[[[[ hostnames=(`niscat hosts.org_dir | awk '{print $1}' | uniq`) ]]]],[[[[ hostnames=(`cat /etc/hosts | awk '{print $2}' | uniq`) ]]]]) #source /usr/local/lib/zsh/examples/func/multicomp compctl -g '*(/D)' rmdir rd dircmp compctl -g '*(D-/)' cd pushd # dcd is a dirstack cd alias function WhatDirs { reply=(`dirs`) } compctl -K WhatDirs dcd compctl -c which whence function compctl -F func functions unfunc unfunction compctl -g '*(*)' -x 'p[2]' -k '(core)' -- dbx debugger strip gprof adb dbx xdbx ups compctl -l '' nohup exec nice eval trap compctl -l '' -x 'p[1]' -B -- builtin compctl -f -x 'p[1]' -R -- alias unalias #compctl -x 'p[1]' -a -- alias compctl -x 'p[1]' -p -- set compctl -x 'p[1]' -E - 'c[-1,DISPLAY]' -k hostnames -S ':0.0 ' -- setenv #For kill function WhatPIDs { reply=(`ps | awk 'NR > 1 {print $1}'`) } compctl -j -x 's[-] p[1]' -k signals - 'p[1,9]' -K WhatPIDs -- kill #compctl -j -P "%" -S " " -x 's[-] p[1]' -k signals -- kill compctl -j -P \'% -S\' fg compctl -z -P \'% -S\' bg compctl -r -P \'% -S\' disown compctl -k hostnames -x 'p[2]' -c - 'c[-1,-display]' -k hostnames - 's[-]' -k '(display geometry)' -- rsh #compctl -k hosts -x 'p[2,-1]' -l '' -- rsh compctl -k hostnames -x 'p[2]' -c - 'c[-1,-display]' -k hostnames - 's[-]' -k '(display geometry)' -- on compctl -x 'n[-1,@]' -k hostnames - 'p[1]' -u -S '@' -- finger write mail mtalk compctl -u -x 'n[-1,@]' -k hostnames - 'p[1]' -u -S '@' -- talk compctl -g 'RCS/*(.D,@:t:s/\,v//)' -X "(Searching RCS Directory)" -x 's[-]' -k "(f I l M p q r u)" -- co compctl -g 'RCS/*(.D,@:t:s/\,v//)' -X "(Searching RCS Directory)" rlog rcsdiff ident compctl -f + -g 'RCS/*(.D,@:t:s/\,v//)' ci compctl -k hostnames -x 'p[2]' -c - 'c[-1,-display]' -k hostnames -S ':0.0 ' - 's[-]' -k '(display geometry)' -- on rsh compctl -k hostnames ping #For telnet -- precompute this? function WhatServices { reply=(`awk '/[^ ]*\/tcp/ {print $2}' /etc/services | sed 's/\/tcp//' | sort -n`) } compctl -k hostnames -x 'p[1]' -k hostnames - 'c[-1,-l]' -u - 'p[-1]' -K WhatServices -- telnet compctl -k hosts -x 'c[-1,-l]' -u -- rlogin #For ftp,ncftp,etc. -- precompute this? function WhatSites { reply=(`awk '{print $1}' ~/.ncrecent` `awk -F, 'NR>2 {print $1}' ~/.ncftp/bookmarks`) reply=(`echo $reply | sort`) } compctl -k hostnames -K WhatSites ftp ncftp tftp compctl -f -x 'R[-*d,^*]' -g '*.gz *.z *.Z' + -g '*(-/)' -- gzip compctl -g '*.gz *.z *.Z' + -g '*(-/D)' gunzip zmore zless uncompress zcat #compctl -g '*.Z' + -g '*(-/)' uncompress compctl -k '(cd floppy)' eject compctl -g '*.h' src2latex compctl -g '*(-/D) *.(ps|PS)*(D)' -x 'S[-][-P]' -P "-P" -k "($printers)" -- lpr compctl -g '*.(ps|PS)' + -g '*(-/D)' gs ghostview psps pstops psmulti psselect pslp2 psnup compctl -g '*.tex*' + -g '*(-/D)' tex latex texi2dvi glatex slitex gslitex compctl -g '*.dvi' + -g '*(-/D)' xdvi dvips dvilj compctl -g '*.cc' + -g '*(-/D)' tcov compctl -g '*.tcov' + -g '*(-/D)' AccumTcovStats CumTcovStats compctl -g '*.h *.h++ *.H' + -g '*(-/D)' src2latex compctl -g '*.tex' + -g '*(-/D)' latex compctl -o setopt unsetopt ZSH_HELP_SECTIONS=(`echo $ZSHELP_DIRECTORY/*(:t:r)`) compctl -k ZSH_HELP_SECTIONS zshelp #compctl -g '*' -P "'a:" -S "'" mdir mcopy mdel mren mrd mcd compctl -g '*(-/D)' -x 'c[-1,-fstype]' -k '(nfs 4.2)' - 'c[-1,-name]' -f - 'c[-1,-type]' -k '(c b d f p l s)' - 'c[-1,-user]' -u - 'c[-1,-exec]' -c - 'c[-1,-ok]' -c - 'c[-1,-cpio]' -f - 'c[-1,-ncpio]' -f - 'c[-1,-newer]' -f - 's[-]' -k '(fstype name perm prune type user nouser group nogroup size inum atime mtime ctime exec ok print ls cpio ncpio newer xdev depth)' -- find compctl -g '*.xd' small_visu compctl -k '(cd floppy)' eject compctl -g '^*,v(D)' rm # xsetroot: gets possible colours, cursors and bitmaps from wherever. # Uses two auxiliary functions. You might need to change the path names. Xcolours() { reply=($(awk '{ print $4 }' < /usr/lib/X11/rgb.txt)) } Xcursor() { reply=($(awk '/^#define/ {print $2}' \ /dev/null; then # You may want to circumvent the package cache if you have a blindingly # fast machine... I don't :-(, so I need the cache. Just comment the first # and third lines of the fn, below. function pkg_glob () { if [[ ${REDHAT_PACKAGES:-0} = 0 ]]; then export REDHAT_PACKAGES="`rpm -qa`" fi reply=(${=REDHAT_PACKAGES}) } function refreshpkgcache () { export REDHAT_PACKAGES="`rpm -qa`" } # Complete for rpm # Line by line comments (it's hard to put them in continuation lines) # --root always takes a -glob of a directory # --install or -i take a gammut of params starting w/ -- # --upgrade or -u take a slightly different gammu also w/ -- # w/just '-' display a message about hash and verbose # --erase and --verify (-e, -V, -y) take --root # or just a package # query takes lots of options, then might take either a file, or a package # depending on what the last character of the preceding argument was # --where, --checksig take package # -- starts the top level options # - starts the top level one character options # if nothing, just show usage. compctl -f -x \ 'c[-1,--root]' -g '*(/)' - \ 'W[1,-(-install|i*)] s[--]' -k (hash percent force test replacepkgs replacefiles search root) - \ 'W[1,-(-upgrade|u*)] s[--]' -k (hash percent force test search oldpackage root) - \ 'C[-1,--(install|upgrade)] s[-],p[1] s[-i],p[1] s[-U]' -X "(h)ash (v)erbose" - \ 'W[1,-(-erase|e|-verify|V|y)] s[--]' -k (root) - \ 'W[1,-(-erase|e)]' -K pkg_glob - \ 'w[1,--query] s[-],p[1] s[-q],p[1] s[-V],p[1] s[-y]' -X \ "(a)ll (f)ile+ (F)ile-stdin (p)kg+ (P)kg-Stdin (i)nfo (l)ist-of-files (s)tates-of-files (d)ocumentation (c)onfiguration" - \ 'w[1,--verify] s[-],p[1] s[-V],p[1] s[-y]' -X \ "(a)ll (f)ile+ (F)ile-stdin (p)kg+ (P)kg-Stdin" - \ 'W[1,-(-verify|-query|q*|V*|y*)] C[-1,*f]' -f - \ 'W[1,-(-verify|-query|q*|V*|y*)] C[-1,*p*]' -g '*(D-/) *.rpm(N)' - \ 'W[1,-(-verify|-query|q*|V*|y*)]' -K pkg_glob - \ 'W[1,--(where|checksig)]' -K pkg_glob - \ 'W[1,--rebuild] s[-]' -k (v) - \ 'p[1] s[-b]' -X "(p)rep (l)ist (c)ompile (i)install (b)inary (a)ll" - \ 'p[2] C[-1,-b*] s[--]' -k (short-circuit clean sign keep-temps test time-check) - \ 's[--]' -k (help version install upgrade query verify erase rebuild where checksig) - \ 's[-]' -k (- i U q V e b) - \ 'c[-1,rpm]' -X "$(rpm)" -- rpm fi #if rpm exists