# This file gives some examples of compctl commands. # You can either put the compctl commands in your .zshrc # or include a separate file from your .zshrc with the # source command. ### # complete database ### # All completions for zsh. if [ -f ~/.ssh/known_hosts ]; then hostnames=(`awk '{print $1}' ~/.ssh/known_hosts|sed 's/,.*//'`) elif [ -f ~/.rhosts ]; then hostnames=(`awk '{print $1}' ~/.rhosts` \ {casgur,minanogawa,kurihara}.prc.tsukuba.ac.jp NSR VFR \ parsley.hiemalis.org caveat.tokyo.yrk.co.jp \ {firestorm,hornet}.gentei.org \ {superblackbird,buell,goose}.itc.keio.ac.jp) else hosnames=(localhost) fi if [ -f ~/.netrc ]; then ftpsites=( `grep '^machine' ~/.netrc | awk '{print $2}'` \ $hosts ) else ftpsites=($hosts) fi # These are just examples, use and modify to personal taste. Copying this # file without thought will needlessly increase zsh's memory usage and # startup time. # For an explanation of what all this means, read either the # introduction for some explanation or the manual for a detailed # description. # Strip, profile, and debug only executables. The compctls for the # debuggers could be better, of course. compctl -g '*(x-)' strip gprof adb dbx xdbx ups # See the func/cdmatch function in the distribution #autoload cdmatch #compctl -K cdmatch -S '/' -x 'S[/][~]' -g '*(-/)' -- cd pushd #compctl -g "*(/)" -S / -x 'S[/][~]' -g '*(-/)' -- cd pushd chdir pu compctl -g "(|.)*(-/)" cd pushd chdir pu apath # For rcs users, co and rlog from the RCS directory. We don't want to see # the RCS and ,v though. compctl -g 'RCS/*(:t:s/\,v//)' + -g '(|.)*(-/)' co rlog rcs # Anything after nohup is a command by itself with its own completion # (the one for the trap builtin isn't perfect -- it does not complete # signal names) compctl -l '' nohup exec nice eval trap time fep sudo compctl -l '' -x 'p[1]' -B -- builtin # kill takes signal names as the first argument after -, but job names after % compctl -j -P % -x 's[-] p[1]' -k signals -- kill # gzip files, but gzip -d only gzipped or compressed files compctl -f -x 'R[-*d,^*]' -g '(|.)*.(gz|z|Z) (|.)*(-/)' + -g '(|.)*(-/)' -- gzip compctl -g '*.gz *.z *.Z' + -g '(|.)*(-/)' gunzip # zcat if you use GNU compctl -g '*.Z' + -g '(|.)*(-/)' uncompress zmore # zcat if you don't use GNU ## compctl -g '*.F' + -g '(|.)*(-/)' melt fcat ## # find is very system dependend, this one is for GNU find. ## compctl -x 's[-]' -k "(daystart depth follow maxdepth mindepth noleaf version xdev \ ## amin anewer cmin cnewer ctime empty false fstype gid group inum links lname mmin \ ## mtime name newer nouser nogroup path perm regex size true type uid used user xtype \ ## exec fprint fprint0 fprintf ok print print0 printf prune ls)" - \ ## 'p[1]' -g '. .. *(-/)' - \ ## 'c[-1,-anewer][-1,-cnewer][-1,-newer][-1,-fprint][-1,fprint0][-1,fprintf]' -f - \ ## 'c[-1,-fstype]' -k '(ufs 4.2 4.3 nfs tmp mfs S51K S52K)' - \ ## 'c[-1,-group]' -s '$(groups)' - \ ## 'c[-1,-user]' -u - \ ## 'r[-exec,;][-ok,;]' -l '' -- find # 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/X11/rgb.txt)) } ## Xcursor() { reply=($(awk '/^#define/ {print $2}' \ ## "3.0" ]]; then compctl -C -c -x \ 's[DISPLAY=]' -k hostnames -S ":0" - \ 's[LANG=]' -k '(japanese ja_JP.eucJP C)' - \ 's[TERM=]' -k '(vt100 kterm xterm news screen pc3 cons25)' - \ 's[LESSCHARSET=]' -k '(japanese jis sjis ujis)' - \ 'C[0,[A-Z][A-Z][A-Z_]*]' -v -S = + \ -k '(LANG JAPANESE LESSCHARSET DISPLAY LD_LIBRARY_PATH LD_RUN_PATH CONF_ADDED_DIR CAAM_ADD CAAM_PREFIXES)' \ -S = - \ 'n[1,=]' -f else compctl -C -c -x \ 's[DISPLAY=]' -k hostnames -S ":0" - \ 's[LANG=]' -k (japanese C) - \ 's[TERM=]' -k (vt100 kterm xterm news screen pc3 cons25) - \ 's[LESSCHARSET=]' -k (japanese jis sjis ujis) - \ 'C[0,[A-Z][A-Z][A-Z_]*]' -v \ -k (LANG JAPANESE LESSCHARSET DISPLAY LD_LIBRARY_PATH) -S = - \ 'n[1,=]' -f fi # Default completion maybe right of parameter assignment if [[ -d /usr/iekei ]]; then _glob_conf_top=/usr/iekei elif [[ -d /usr/koeki ]]; then _glob_conf_top=/usr/koeki else _glob_conf_top=/usr/local fi _glob_conf() { local a n read -cA a read -cn n local pat=${a[$n]#*=} pat=${pat##*\:} reply=(`(cd $_glob_conf_top; echo ${pat}*(/N))`) } compctl -D -f -x \ 'C[-1,DISPLAY=*]' -k hostnames -S ":0" - \ 'C[-1,LANG=*]' -k "(japanese ja_JP.eucJP C)" - \ 'C[-1,PAGER=*]' -k "(less more)" - \ 'C[-1,TERM=*]' -k "(vt100 kterm xterm news screen)" - \ 'C[-1,(CONF_ADDED_DIR|CAAM_ADD)=*] n[-1,:]' \ -K _glob_conf -S '' - \ 'C[-1,(CONF_ADDED_DIR|CAAM_ADD)=*]' -K _glob_conf -S '' - \ 'C[-1,*PATH*=*] n[-1,:]' -f - \ 'C[-1,*PATH*=*]' -f - \ 'C[-1,LESSCHARSET=*]' -k "(japanese jis sjis ujis)" # setenv (personal function) compctl -f -x \ 'p[1]' -v + -k "(LANG DISPLAY TERM LESSCHARSET)" - \ 'c[-1,DISPLAY]' -k hostnames -S ":0" - \ 'c[-1,LANG]' -k "(japanese C)" - \ 'c[-1,PAGER]' -k "(less more)" - \ 'c[-1,TERM]' -k "(vt100 kterm xterm news screen)" - \ 'c[-1,LESSCHARSET]' -k "(japanese jis sjis ujis)" -- setenv # export compctl -f -x \ 'n[1,DISPLAY=]' -k hostnames -S ":0" - \ 'n[1,LANG=]' -k "(japanese C)" - \ 'n[1,PAGER=]' -k "(less more)" - \ 'n[1,TERM=]' -k "(vt100 kterm xterm news screen)" - \ 'n[1,LESSCHARSET=]' -k "(japanese jis sjis ujis)" - \ 'p[1]' -v -S = + -k "(LANG DISPLAY TERM LESSCHARSET)" -S = -- export # printenv compctl -v printenv # Similar things for tex, texinfo and dvi files. compctl -g '*.tex*' + -g '*(-/)' {j,{,u}p,lua,xe,pdf}{,la}tex ptex2pdf compctl -g '*.dvi' + -g '*(-/)' dvipdfmx compctl -g '*(-/) *.dvi' -x \ 'c[-1,-o]' -k "(landscape a5 b4 b4landscape)" -- dvi2ps compctl -g '*(-/) *.dvi' -x \ 's[-]' -k '(p l o r)' - \ 'c[-1,-o]' -g '*(-/) *.dvi(:s/dvi/ps/)' -- dvips compctl -g '*(-/) *.ps' -x \ 'C[-1,*.ps]' -g '*(-/) *.ps(:s/ps/pdf/)' -- ps2pdf ### # for archivers and compression tools ### compctl -f -x 'p[1,2]' \ -g "*(-/) *.[Ll][Zz][Hh] *.[Ee][Xx][Ee]" -- lha lhp compctl -f -x 'p[1]' -g "*(-/) *.[Aa][Rr][Cc]" -- arc compctl -f -x 'p[1,2]' -g "*(-/) *.([Zz][Ii][Pp]|[Jj][Aa][Rr])" -- zip unzip compctl -f -x 'p[1,2]' -g "*(-/) *.[Aa][Rr][Jj]" -- unarj compctl -g "*(-/) *.(Z|z|gz)" zmore zless zgrep zcmp ### # for printers ### printers=(sp620 cclbp{9,c}) compctl -f -x 's[-P]' -k "($printers)" -- lp{r{,m},q} compctl -f -x 'p[1]' -k "(abort enable disable help restart status topq \ clean down start stop up)" - \ 'p[2]' -k "($printers)" -- lpc unset printers ### # for X clients ### winopt=(geometry display fg bg fn popup_geometry) # The next line is the template # 's[-]' -k winopt - 'c[-1,-display]' -k hostnames -S ':0 ' compctl -x \ 'c[-1,-e]' -l '' - \ 's[-]' -k winopt - 'c[-1,-display]' -k hostnames -S ':0 ' - \ 'c[-1,-wp]' -g '*(-/) *.xpm' - \ 'c[-1,-geometry]' -k "(+0+0 80x37+0+0 80x26+0+0)" -- kterm xterm compctl -g '*.dvi *(-/)' -x \ 's[-]' -k "($winopt s S p l paper keep rv)" - \ 'c[-1,-paper]' -k "(a4r)" - \ 'c[-1,-display]' -k hostnames -S ':0 ' -- xdvi compctl -g "*.ps *.eps *.(pdf|png|jpg) ^*.* *(-/)" -x \ 's[-]' -k winopt - 'c[-1,-display]' -k hostnames -S ':0 ' \ -- ghostview gs compctl -caF -x \ 'p[1],C[-1,-[1246AaCfgkMNnqsTtVvXxY]][-2,-[bcDeFiLlmOopRS]]' \ -k hostnames - \ 'c[-1,-l]' -k "(yuuji)" - \ 'C[-1,-[RL]] C[0,[0-9]*] n[1,:]' -k hostnames -S : - \ 's[-]' -k winopt - 'c[-1,-display]' -k '($DISPLAY)' -S ' ' - \ 'p[-1]' -l '' -- {,s}ssh compctl -x \ 's[-]' -k winopt - \ 'c[-1,-display]' -k hostnames -S ':0 ' - \ 'c[-1,-file]' -f - \ 'C[-1,-*geometry]' -k '(+0+0 +400+0 -0+0)' -- xpbiff xbiff glob_netscape () { local n a p read -cA a read -cn n p=`echo $a[$n]|sed 's,.*~yuuji/,,'` reply=(~/http/$^p*(N:s,$HOME/http/,,)) } compctl -x \ 's[http://vfr/~yuuji/]' -K glob_netscape -- netscape # C compilers compctl -g "*.[cCoa]" -x 's[-I][-L]' -g "*(/)" - \ 'C[-1,-o]' -g "*.c(:r)" - \ 's[-l]' -s '${(s.:.)^LD_LIBRARY_PATH}/lib*.a(:t:r:s/lib//) \ /usr/{,*/}lib/lib*.a(:t:r:s/lib//)' -- cc gcc # Java compiler and interpreter compctl -g "*(-/) *.java" javac compctl -g "*.class(:r)" -x \ 'p[2,-1]' -f -- java kaffe ### # for netpbm ### compctl -f -x 's[-]' -k '(interlace transparent)' -- ppmtogif compctl -f -x 'p[1]' -k '(256 200)' -S ' | ppmtogif' -- ppmquant ### # for ImageMagick ### compctl -f -x \ 's[-]' -k '(colors delay gamma geometry interlace monochrome \ quality rotate)' - \ 'c[-1,-interlace]' -k '(line none plane partition)' \ -- convert mogrify display ### # Miscellaneous ### # GNU Emacs compctl -g "^*[#~] .*" -x \ 's[-]' -k "(user nw batch e insert kill load display geometry)" - \ 's[+]' -X "Line number" - \ 'c[-2,-batch] c[-1,-e]' -k "(batch-byte-compile)" - \ 'c[-1,-batch]' -k "(-e)" -S ' batch-byte-compile ' - \ 'c[-1,-e]' -k "(mew mh-rmail mh-smail resume-windows trr)" - \ 'c[-1,-display]' -k hostnames -S ":0 " - \ 'c[-1,-geometry]' -k "(+0+0 80x37+0+0 80x26+0+0)" - \ 'c[-1,-user]' -u -- mule $emacs m1 canna {x,}emacs compctl -g "*(-/)" -x \ '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)' - \ 'c[-1,-type]' -k '(c b d f p l s)' - 'c[-1,-user]' -u - \ 'r[-exec,;][-ok,;]' -l '' -- find compctl -x \ 'c[-1,-f]' -g "[Mm]ake* *.[Mm]*[Kk] *(-/)" - \ 's[CC]' -P "='" -k '(gcc cc)' -S " -pipe" - \ 'S[CF]' -S "='" -k '(CFLAGS)' - \ 's[-I],s[-L]' -g "*(-/)" -- make gmake # compctl -g "(|.)*~*.[ch] *(-/)" rm compctl -f -x \ 's[-T]' -k '(nippon dvi ps X100)' - \ 's[-]' -k '(ms man T)' -S '' - \ 'c[-1,-man]' -g "*.[0-9] *.man *(-/)" -- nroff jgroff compctl -g "(|*).obj *(-/)" tgif prtgif compctl -f -x \ 's[-]' -k '(s R mv rm mkindex refresh pick flush perf \ delete reclassify)' - \ -- ftpurl compctl -g "(|*).(smc|SMC)(|.gz) *(-/)" snes9x compctl -g "(|*).(nes|NES)(|.gz) *(-/)" ines compctl -x 's[if=],s[of=]' -f -- dd compctl -x \ 'n[1,freebsd]' -k '(7 6 5 4 3.2 3.4)' - \ 'n[1,netbsd]' -s '{3,4}.{1,2,3,0}' - \ 'n[1,openbsd]' -k '(3 4)' - \ 'n[1,i386-]' -k '(pc-freebsd pc-netbsd pc-openbsd)' -S '' - \ 'n[1,i586-]' -k '(pc-freebsd pc-netbsd pc-openbsd)' -S '' - \ 'n[1,i686-]' -k '(pc-freebsd pc-netbsd pc-openbsd)' -S '' - \ 'n[1,x86_64-]' -k '(pc-freebsd pc-netbsd pc-openbsd)' -S '' - \ 'n[1,=i]' -k '(686-pc-freebsd 686-pc-netbsd 686-pc-openbsd)' -S '' - \ 'n[1,=x]' -s '86_64-pc-{free,net,open}'bsd -S '' - \ 'n[1,=]' -k '(yes no)' + -f - \ 's[--]' -k '(prefix disable with-mule program-prefix target build \ with-canna with-canna-libraries with-canna-includes)' -S '=' - \ 's[x]' -k '(86_64)' -S -'' - \ 's[i]' -k '(386 586 686)' -S -'' - \ 'S[s]' -k '(sparc-sun-netbsd1.3.1 sparc-sun-openbsd2.8)' -S '' - \ -- configure \*conf keisuke caam glob_syncdir () { local n a p=1 table=${SYNCDIRTABLE:-~/.syncdir} lo read -cA a #コマンドライン全体を配列 a に入れる read -cn n #カーソルの引数位置を n に入れる while [[ $p -lt $n ]] { [[ -f $a[$p] && "$lo" = "-f" ]] && table=$a[$p] lo=$a[$p] p=$[++p] } reply=(`sed -n "/^[A-z]/s/:.*//p" $table`) } compctl -g "(.|)*(-/)" -x \ 's[-]' -k '(d l L e n N p x q f V r a A)' - \ 'c[-1,-f]' -f - \ 'c[-1,-V] n[-1,,],c[-1,-V]' -K glob_syncdir -S , -q -- syncdir compctl -f -x \ 'r[-graft-points] n[1,=]' -f -X '<>' - \ 's[-]' -k '(DNRJ DNRJV o b dvd-video graft-points)' \ -- mkhybrid mkisofs compctl -g "(.|)*(-/)" -x \ 's[-]' -k '(x)' -S " -B -S 4 -D " - \ 'c[-1,-D]' -k '(/dev/rcd0d)' -- cdda2wav compctl -g "(.|)*(-/)" + -f -x \ 's[dev=]' -k '(/dev/cd0d 0\,6\,0 0\,5\,0)' - \ 's[speed=]' -V speed -k '(1 2 4 8 16 32)' - \ 's[blank=]' -k \ '(help all disk fast minimal track trtail unclose session)' - \ 'S[sp]' -k '(speed)' -S '=' + -f - \ 'S[de]' -k '(dev)' -S '=' + -f - \ 'S[bl]' -k '(blank)' -S '=' + -f - \ 's[-]' -k '(v dummy eject data audio msinfo multi swab)' -S " " - \ -- {cd,dvd}record # xxx is workaround for zsh 3.1.x \ # 'r[-R,xxx][-RJ,xxx]' -l mkisofs - \ compctl -x \ 's[-speed=]' -V '' -k '(4 8 16 32)' - \ 'r[-R,xxx][-RJ,xxx]' -l mkisofs - \ 'C[-1,-[MZ]] n[1,=]' -f - \ 'C[-1,-[MZ]] r[-dvd-compat,xxx]' -V '' -k \ '(/dev/rcd0d /dev/rcd1d /dev/acd0)' -S '=' -q + -f - \ 'C[-1,-[MZ]]' -V '' -k \ '(/dev/rcd0d /dev/rcd1d /dev/acd0)' -S ' ' + -f - \ 'S[-s]' -k '(-speed)' -S '=' - \ 's[-]' -k '(dry-run dvd-compat overburn speed Z M)' -- growisofs compctl -g "(|*).mp3 *(-/)" mpg123 compctl -g "(|*).ogg *(-/)" ogg123 ogginfo oggdec compctl -g '*(-/) *.wav' -x \ 's[-]' -k '(nopsy)' - \ 'C[-1,*.wav]' -g '*(-/) *.wav(:s/wav/mp3/)' -- gogo compctl -g '*(-/) *.wav' -x \ 's[-]' -k '(nopsy)' - \ 'C[-1,*.wav]' -g '*(-/) *.wav(:s/wav/mp3/)' -- oggenc compctl -f -x \ 'p[1]' -k '(show-toc toc-info toc-size read-toc read-cd read-cddb show-data read-test disk-info msinfo unlock blank scanbus simulate write copy)' - \ 'c[-1,--device]' -k '(/dev/cd0d 0\,5\,0)' - \ 's[-]' -k '(-speed)' -S " 16 --eject --overrun --device /dev/cd0d " - \ -- cdrdao compctl -g "(|*).(jpg|gif|png|bmp|xcf|gz|bz2|xz) *(-/)" gimp compctl -f -x \ 's[-p]' -k '(0 1 2 3)' -S ' ' - \ 'c[-1,-d]' -g "(|.)*(-/)" - \ 's[-]' -k '(p d R s)' -- patch compctl -g "(|*).(pdf|PDF|(e|)ps) *(-/)" evince acroread chflagsflags=({,no}{arch,opaque,nodump,sappnd,schg,uappnd,uchg}) compctl -x \ 's[-]' -k '(R H L P)' - \ 'n[-1,,]' -k chflagsflags -q -S , - \ 'C[-1,-*]' -k chflagsflags - \ 'p[1]' -k chflagsflags - \ 'C[-1,[^-]*],p[2,-1]' -f - -- chflags mplayergeoms=(400:300 640:480 320:240 720:480 360:240) compctl -f -x \ 'n[1,vbitrate=] c[-1,-lavcopts]' -s '500 700 1200' -S '' - \ 'c[-1,-lavcopts] n[-1,:]' -k '(vhq)' -q -S : + -k '(vbitrate)' -S = - \ 's[vcodec=]' -k '(mpeg4 msmpeg4 mjpeg h263 h263p rv10 mpeg1video)' - \ 'n[1,crop=][1,expand=][1,scale=] c[-1,-vop] C[0,*[=0-9]]' \ -k mplayergeoms -S ',' -q - \ 'c[-1,-vop] n[-1,,]' -k "(crop expand scale lavcdeint expand)" -q -S = - \ 'c[-1,-lavcopts]' -s 'vcodec' -S = - \ 'c[-1,-ovc]' -k '(copy divx4 rawrgb lavc)' - \ 'c[-1,-oac]' -k '(copy pcm mp3lame)' - \ 'c[-1,-o]' -g "(*|).*(:r) *(-/)" - \ 'c[-1,-vop]' -k "(crop scale lavcdeint)" -S = - \ 's[-]' -k '(oac ovc lavcopts o delay channels ofps vop)' - \ 'c[-1,mencoder]' -k '(-)' \ -S "ovc lavc -oac mp3lame -lavcopts vcodec=mpeg4:vbitrate=700 -ofps 30 -" \ -- mencoder # 'c[-1,-lameopts]' -k # 'n[1,scale=] c[-1,-vop]' -k '(400:300 640:480 320:240)' -S , - \ compctl -g "*.(avi|mov|mp(eg|)[1234]|wm[av]|webm|og[gv]) *(-/)" -x \ 'n[1,scale=] c[-1,-vop]' -k mplayergeoms -S , -q - \ 'c[-1,-delay]' -k '(0.5 1.1 -1.1)' - \ 'c[-1,-dvd-device]' -k "(/dev/rcd0d /dev/rcd1d /dev/acd0)" - \ 'c[-1,-vop]' -k "(expand scale lavcdeint)" -S = -q - \ 'c[-1,-af] n[-1,volume=]' -k '(2 4 8 10 12)' \ -X '<>' - \ 'c[-1,-af]' -k "(volume)" -S = - \ 'c[-1,-af]' -k "(scaletempo)" - \ 's[dvd://]' -s "{1..10}" - \ 's[dvd]' -s "://" -S '' - \ 's[-]' -k '(zoom fs delay framedrop frames dvd-device vf af volume)' \ -- mplayer compctl -x \ 's[-]' -s 'next prev' - \ 'c[-1,xvidtune]' -k '(-next -prev)' -- xvidtune compctl -g "/service/*(-/:t)" -x \ 's[-]' -k '(f)' -- dtlog compctl -g "*.mgp *(-/)" -x \ 'c[-1,-g]' -k '(1024x768 800x600)' - \ 'c[-1,w]' -g "*(-/)" - \ 's[-]' -k '(g w)' -- mgp typeset -U _mixerctl_vars2 glob_mixerctl () { local cmdline if [[ -z $_mixerctl_vars ]]; then set -A _mixerctl_vars ${$(mixerctl -a)%\=*} set -A _mixerctl_vars2 ${(R)${(fs: :)_mixerctl_vars}%%.*} fi read -cA cmdline if [[ $cmdline[-1] == *.* ]]; then reply=($_mixerctl_vars) else # reply=(${(R)${(fs: :)_mixerctl_vars}%%.*}) reply=($_mixerctl_vars2) fi } compctl -x \ 'C[-1,-w][-1,mixerctl] S[inputs.][outputs.][record.][spdif.]' \ -K glob_mixerctl -q -S '=' - \ 'C[-1,-w][-1,mixerctl]' -K glob_mixerctl -S '.' - \ 's[-]' -k '(w a)' -- mixerctl _pkgsrc_apps() { local pdir=${PKGSRC:-/opt/pkgsrc} line cur read -cA line if [[ -z $_pkgsrc_dirs ]]; then set -A _pkgsrc_dirs $^pdir/(*~CVS)/(*~CVS)(N-/:s,$pdir/,) set -A _pkgsrc_dirs2 $^pdir/(*~CVS)(N-/:t) fi cur=${line[-1]} case $cur in */*) reply=($_pkgsrc_dirs) ;; *) reply=($_pkgsrc_dirs2) ;; esac } compctl -K _pkgsrc_apps -S '/' -q -x \ 's[-]' -k '(n p P j w s d N M U i a b C t)' - \ 'C[-1,-[psPwdDt]]' -g "*(-/)" - \ 'c[-1,-j]' -k "(`echo {1..12}`)" \ -- pkgsrc-newprefix compctl -f df