complete.tcsh revision 145479
1#
2# $Id: complete.tcsh,v 1.46 2005/03/21 21:26:08 kim Exp $
3# example file using the new completion code
4#
5# Debian GNU/Linux
6# /usr/share/doc/tcsh/examples/complete.gz
7#
8# This file may be read from user's ~/.cshrc or ~/.tcshrc file by
9# decompressing it into the home directory as ~/.complete and
10# then adding the line "source ~/.complete" and maybe defining
11# some of the shell variables described below.
12#
13# Added two Debian-specific completions: dpkg and dpkg-deb (who
14# wrote them?). Changed completions of several commands. The ones
15# are evaluated if the `traditional_complete' shell variable is
16# defined.
17#
18# Debian enhancements by Vadim Vygonets <vadik@cs.huji.ac.il>.
19# Bugfixes and apt completions by Miklos Quartus <miklos.quartus@nokia.com>.
20# Cleanup by Martin A. Godisch <martin@godisch.de>.
21
22onintr -
23if (! $?prompt) goto end
24
25if ($?tcsh) then
26    if ($tcsh != 1) then
27   	set rev=$tcsh:r
28	set rel=$rev:e
29	set pat=$tcsh:e
30	set rev=$rev:r
31    endif
32    if ($rev > 5 && $rel > 1) then
33	set _complete=1
34    endif
35    unset rev rel pat
36endif
37
38if ($?_complete) then
39    set noglob
40    if ( ! $?hosts ) set hosts
41    foreach f ($HOME/.hosts /usr/local/etc/csh.hosts $HOME/.rhosts /etc/hosts.equiv)
42        if ( -r $f ) then
43	    set hosts = ($hosts `grep -v "+" $f | grep -E -v "^#" | tr -s " " "	" | cut -f 1`)
44	endif
45    end
46    if ( -r $HOME/.netrc ) then
47	set f=`awk '/machine/ { print $2 }' < $HOME/.netrc` >& /dev/null
48	set hosts=($hosts $f)
49    endif
50    if ( -r $HOME/.ssh/known_hosts ) then
51	set f=`cat $HOME/.ssh/known_hosts | cut -f 1 -d \ ` >& /dev/null
52	set f=`cat $HOME/.ssh/known_hosts | cut -f 1 -d \ | sed -e 's/,/ /g'` >& /dev/null
53	set hosts=($hosts $f)
54    endif
55    unset f
56    if ( ! $?hosts ) then
57	set hosts=(hyperion.ee.cornell.edu phaeton.ee.cornell.edu \
58		   guillemin.ee.cornell.edu vangogh.cs.berkeley.edu \
59		   ftp.uu.net prep.ai.mit.edu export.lcs.mit.edu \
60		   labrea.stanford.edu sumex-aim.stanford.edu \
61		   tut.cis.ohio-state.edu)
62    endif
63
64    complete ywho  	n/*/\$hosts/	# argument from list in $hosts
65    complete rsh	p/1/\$hosts/ c/-/"(l n)"/   n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/
66    complete ssh	p/1/\$hosts/ c/-/"(l n)"/   n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/
67    complete xrsh	p/1/\$hosts/ c/-/"(l 8 e)"/ n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/
68    complete rlogin 	p/1/\$hosts/ c/-/"(l 8 e)"/ n/-l/u/
69    complete telnet 	p/1/\$hosts/ p/2/x:'<port>'/ n/*/n/
70
71    complete cd  	p/1/d/		# Directories only
72    complete chdir 	p/1/d/
73    complete pushd 	p/1/d/
74    complete popd 	p/1/d/
75    complete pu 	p/1/d/
76    complete po 	p/1/d/
77    complete complete 	p/1/X/		# Completions only
78    complete uncomplete	n/*/X/
79    complete exec 	p/1/c/		# Commands only
80    complete trace 	p/1/c/
81    complete strace 	p/1/c/
82    complete which	n/*/c/
83    complete where	n/*/c/
84    complete skill 	p/1/c/
85    complete dde	p/1/c/ 
86    complete adb	c/-I/d/ n/-/c/ N/-/"(core)"/ p/1/c/ p/2/"(core)"/
87    complete sdb	p/1/c/
88    complete dbx	c/-I/d/ n/-/c/ N/-/"(core)"/ p/1/c/ p/2/"(core)"/
89    complete xdb	p/1/c/
90    complete gdb	n/-d/d/ n/*/c/
91    complete ups	p/1/c/
92    complete set	'c/*=/f/' 'p/1/s/=' 'n/=/f/'
93    complete unset	n/*/s/
94    complete alias 	p/1/a/		# only aliases are valid
95    complete unalias	n/*/a/
96    complete xdvi 	n/*/f:*.dvi/	# Only files that match *.dvi
97    complete dvips 	n/*/f:*.dvi/
98    if ($?traditional_complete) then
99        complete tex 	n/*/f:*.tex/	# Only files that match *.tex
100    else
101        complete tex 	n/*/f:*.{tex,texi}/	# Files that match *.tex and *.texi
102    endif
103    complete latex 	n/*/f:*.{tex,ltx}/
104    complete su		c/--/"(login fast preserve-environment command shell \
105			help version)"/	c/-/"(f l m p c s -)"/ \
106			n/{-c,--command}/c/ \
107			n@{-s,--shell}@'`cat /etc/shells`'@ n/*/u/
108    complete cc 	c/-[IL]/d/ \
109              c@-l@'`\ls -1 /usr/lib/lib*.a | sed s%^.\*/lib%%\;s%\\.a\$%%`'@ \
110			c/-/"(o l c g L I D U)"/ n/*/f:*.[coasi]/
111    complete acc 	c/-[IL]/d/ \
112       c@-l@'`\ls -1 /usr/lang/SC1.0/lib*.a | sed s%^.\*/lib%%\;s%\\.a\$%%`'@ \
113			c/-/"(o l c g L I D U)"/ n/*/f:*.[coasi]/
114    complete gcc 	c/-[IL]/d/ \
115		 	c/-f/"(caller-saves cse-follow-jumps delayed-branch \
116		               elide-constructors expensive-optimizations \
117			       float-store force-addr force-mem inline \
118			       inline-functions keep-inline-functions \
119			       memoize-lookups no-default-inline \
120			       no-defer-pop no-function-cse omit-frame-pointer \
121			       rerun-cse-after-loop schedule-insns \
122			       schedule-insns2 strength-reduce \
123			       thread-jumps unroll-all-loops \
124			       unroll-loops syntax-only all-virtual \
125			       cond-mismatch dollars-in-identifiers \
126			       enum-int-equiv no-asm no-builtin \
127			       no-strict-prototype signed-bitfields \
128			       signed-char this-is-variable unsigned-bitfields \
129			       unsigned-char writable-strings call-saved-reg \
130			       call-used-reg fixed-reg no-common \
131			       no-gnu-binutils nonnull-objects \
132			       pcc-struct-return pic PIC shared-data \
133			       short-enums short-double volatile)"/ \
134		 	c/-W/"(all aggregate-return cast-align cast-qual \
135		      	       comment conversion enum-clash error format \
136		      	       id-clash-len implicit missing-prototypes \
137		      	       no-parentheses pointer-arith return-type shadow \
138		      	       strict-prototypes switch uninitialized unused \
139		      	       write-strings)"/ \
140		 	c/-m/"(68000 68020 68881 bitfield fpa nobitfield rtd \
141			       short c68000 c68020 soft-float g gnu unix fpu \
142			       no-epilogue)"/ \
143		 	c/-d/"(D M N)"/ \
144		 	c/-/"(f W vspec v vpath ansi traditional \
145			      traditional-cpp trigraphs pedantic x o l c g L \
146			      I D U O O2 C E H B b V M MD MM i dynamic \
147			      nodtdlib static nostdinc undef)"/ \
148		 	c/-l/f:*.a/ \
149		 	n/*/f:*.{c,C,cc,o,a,s,i}/
150    complete g++ 	n/*/f:*.{C,cc,o,s,i}/
151    complete CC 	n/*/f:*.{C,cc,cpp,o,s,i}/
152    complete rm 	c/--/"(directory force interactive verbose \
153			recursive help version)"/ c/-/"(d f i v r R -)"/ \
154			n/*/f:^*.{c,cc,C,h,in}/	# Protect precious files
155    complete vi 	n/*/f:^*.[oa]/
156    complete bindkey    N/-a/b/ N/-c/c/ n/-[ascr]/'x:<key-sequence>'/ \
157			n/-[svedlr]/n/ c/-[vedl]/n/ c/-/"(a s k c v e d l r)"/\
158			n/-k/"(left right up down)"/ p/2-/b/ \
159			p/1/'x:<key-sequence or option>'/
160
161    complete find 	n/-fstype/"(nfs 4.2)"/ n/-name/f/ \
162		  	n/-type/"(c b d f p l s)"/ n/-user/u/ n/-group/g/ \
163			n/-exec/c/ n/-ok/c/ n/-cpio/f/ n/-ncpio/f/ n/-newer/f/ \
164		  	c/-/"(fstype name perm prune type user nouser \
165		  	     group nogroup size inum atime mtime ctime exec \
166			     ok print ls cpio ncpio newer xdev depth \
167			     daystart follow maxdepth mindepth noleaf version \
168			     anewer cnewer amin cmin mmin true false uid gid \
169			     ilname iname ipath iregex links lname empty path \
170			     regex used xtype fprint fprint0 fprintf \
171			     print0 printf not a and o or)"/ \
172			     n/*/d/
173
174    complete -%*	c/%/j/			# fill in the jobs builtin
175    complete {fg,bg,stop}	c/%/j/ p/1/"(%)"//
176
177    complete limit	c/-/"(h)"/ n/*/l/
178    complete unlimit	c/-/"(h)"/ n/*/l/
179
180    complete -co*	p/0/"(compress)"/	# make compress completion
181						# not ambiguous
182    if ($?traditional_complete) then
183        complete zcat	n/*/f:*.Z/
184    else
185        # "zcat" may be linked to "compress" or "gzip"
186        if (-X zcat) then
187            zcat --version >& /dev/null
188            if ($status != 0) then
189                complete zcat	n/*/f:*.Z/
190            else
191                complete zcat	c/--/"(force help license quiet version)"/ \
192				c/-/"(f h L q V -)"/ n/*/f:*.{gz,Z,z,zip}/
193	    endif
194        endif
195    endif
196
197    complete finger	c/*@/\$hosts/ n/*/u/@ 
198    complete ping	p/1/\$hosts/
199    complete traceroute	p/1/\$hosts/
200
201    complete {talk,ntalk,phone}	p/1/'`users | tr " " "\012" | uniq`'/ \
202		n/*/\`who\ \|\ grep\ \$:1\ \|\ awk\ \'\{\ print\ \$2\ \}\'\`/
203
204    complete ftp	c/-/"(d i g n v)"/ n/-/\$hosts/ p/1/\$hosts/ n/*/n/
205
206    # this one is simple...
207    #complete rcp c/*:/f/ C@[./\$~]*@f@ n/*/\$hosts/:
208    # From Michael Schroeder <mlschroe@immd4.informatik.uni-erlangen.de> 
209    # This one will rsh to the file to fetch the list of files!
210    complete rcp 'c%*@*:%`set q=$:-0;set q="$q:s/@/ /";set q="$q:s/:/ /";set q=($q " ");rsh $q[2] -l $q[1] ls -dp $q[3]\*`%' 'c%*:%`set q=$:-0;set q="$q:s/:/ /";set q=($q " ");rsh $q[1] ls -dp $q[2]\*`%' 'c%*@%$hosts%:' 'C@[./$~]*@f@'  'n/*/$hosts/:'
211
212    complete dd c/--/"(help version)"/ c/[io]f=/f/ \
213		c/conv=*,/"(ascii ebcdic ibm block unblock \
214			    lcase notrunc ucase swab noerror sync)"/,\
215		c/conv=/"(ascii ebcdic ibm block unblock \
216			  lcase notrunc ucase swab noerror sync)"/,\
217	        c/*=/x:'<number>'/ \
218		n/*/"(if of conv ibs obs bs cbs files skip file seek count)"/=
219
220    complete nslookup   p/1/x:'<host>'/ p/2/\$hosts/
221
222    complete ar c/[dmpqrtx]/"(c l o u v a b i)"/ p/1/"(d m p q r t x)"// \
223		p/2/f:*.a/ p/*/f:*.o/
224
225    # these should be merged with the MH completion hacks below - jgotts
226    complete {refile,sprev,snext,scan,pick,rmm,inc,folder,show} \
227		c@+@F:$HOME/Mail/@
228
229    # these and interrupt handling from Jaap Vermeulen <jaap@sequent.com>
230    complete {rexec,rxexec,rxterm,rmterm} \
231			'p/1/$hosts/' 'c/-/(l L E)/' 'n/-l/u/' 'n/-L/f/' \
232			'n/-E/e/' 'n/*/c/'
233    complete kill	'c/-/S/' 'c/%/j/' \
234			'n/*/`ps -u $LOGNAME | awk '"'"'{print $1}'"'"'`/'
235
236    # these from Marc Horowitz <marc@cam.ov.com>
237    complete attach 'n/-mountpoint/d/' 'n/-m/d/' 'n/-type/(afs nfs rvd ufs)/' \
238		    'n/-t/(afs nfs rvd ufs)/' 'n/-user/u/' 'n/-U/u/' \
239		    'c/-/(verbose quiet force printpath lookup debug map \
240			  nomap remap zephyr nozephyr readonly write \
241			  mountpoint noexplicit explicit type mountoptions \
242			  nosetuid setuid override skipfsck lock user host)/' \
243		    'n/-e/f/' 'n/*/()/'
244    complete hesinfo	'p/1/u/' \
245			'p/2/(passwd group uid grplist pcap pobox cluster \
246			      filsys sloc service)/'
247
248    # these from E. Jay Berkenbilt <ejb@ERA.COM>
249    # = isn't always followed by a filename or a path anymore - jgotts
250    if ($?traditional_complete) then
251        complete ./configure \
252			 'c/--*=/f/' 'c/--{cache-file,prefix,exec-prefix,\
253    				bindir,sbindir,libexecdir,datadir,\
254				sysconfdir,sharedstatedir,localstatedir,\
255				libdir,includedir,oldincludedir,infodir,\
256				mandir,srcdir}/(=)//' \
257			 'c/--/(cache-file verbose prefix exec-prefix bindir \
258			 	sbindir libexecdir datadir sysconfdir \
259				sharedstatedir localstatedir libdir \
260				includedir oldincludedir infodir mandir \
261				srcdir)//'
262    else
263	complete ./configure \
264			'c@--{prefix,exec-prefix,bindir,sbindir,libexecdir,datadir,sysconfdir,sharedstatedir,localstatedir,infodir,mandir,srcdir,x-includes,x-libraries}=*@x:<directory e.g. /usr/local>'@ \
265 			'c/--cachefile=*/x:<filename>/' \
266  			'c/--{enable,disable,with}-*/x:<feature>//' \
267 			'c/--*=/x:<directory>//' \
268  			'c/--/(prefix= exec-prefix= bindir= \
269			sbindir= libexecdir= datadir= sysconfdir= \
270   			sharedstatedir= localstatedir= infodir= \
271			mandir= srcdir= x-includes= x-libraries= cachefile= \
272 			enable- disable- with- \
273 			help no-create quiet silent version verbose )//'
274    endif
275    complete gs 'c/-sDEVICE=/(x11 cdjmono cdj550 epson eps9high epsonc \
276			      dfaxhigh dfaxlow laserjet ljet4 sparc pbm \
277			      pbmraw pgm pgmraw ppm ppmraw bit)/' \
278		'c/-sOutputFile=/f/' 'c/-s/(DEVICE OutputFile)/=' \
279		'c/-d/(NODISPLAY NOPLATFONTS NOPAUSE)/' 'n/*/f/'
280    complete perl	'n/-S/c/'
281    complete printenv	'n/*/e/'
282    complete sccs	p/1/"(admin cdc check clean comb deledit delget \
283			delta diffs edit enter fix get help info \
284			print prs prt rmdel sccsdiff tell unedit \
285			unget val what)"/
286    complete setenv	'p/1/e/' 'c/*:/f/'
287
288    # these and method of setting hosts from Kimmo Suominen <kim@tac.nyc.ny.us>
289    if ( -f $HOME/.mh_profile && -x "`which folders`" ) then 
290
291    if ( ! $?FOLDERS ) setenv FOLDERS "`folders -fast -recurse`"
292    if ( ! $?MHA )     setenv MHA     "`ali | sed -e '/^ /d' -e 's/:.*//'`"
293
294    set folders = ( $FOLDERS )
295    set mha = ( $MHA )
296
297    complete ali \
298        'c/-/(alias nolist list nonormalize normalize nouser user help)/' \
299        'n,-alias,f,'
300
301    complete anno \
302        'c/-/(component noinplace inplace nodate date text help)/' \
303        'c,+,$folders,'  \
304        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
305
306    complete burst \
307        'c/-/(noinplace inplace noquiet quiet noverbose verbose help)/' \
308        'c,+,$folders,'  \
309        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
310
311    complete comp \
312        'c/-/(draftfolder draftmessage nodraftfolder editor noedit file form nouse use whatnowproc nowhatnowproc help)/' \
313        'c,+,$folders,'  \
314        'n,-whatnowproc,c,'  \
315        'n,-file,f,'\
316        'n,-form,f,'\
317        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
318
319    complete dist \
320        'c/-/(noannotate annotate draftfolder draftmessage nodraftfolder editor noedit form noinplace inplace whatnowproc nowhatnowproc help)/' \
321        'c,+,$folders,'  \
322        'n,-whatnowproc,c,'  \
323        'n,-form,f,'\
324        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
325
326    complete folder \
327        'c/-/(all nofast fast noheader header nopack pack noverbose verbose norecurse recurse nototal total noprint print nolist list push pop help)/' \
328        'c,+,$folders,'  \
329        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
330
331    complete folders \
332        'c/-/(all nofast fast noheader header nopack pack noverbose verbose norecurse recurse nototal total noprint print nolist list push pop help)/' \
333        'c,+,$folders,'  \
334        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
335
336    complete forw \
337        'c/-/(noannotate annotate draftfolder draftmessage nodraftfolder editor noedit filter form noformat format noinplace inplace digest issue volume whatnowproc nowhatnowproc help)/' \
338        'c,+,$folders,'  \
339        'n,-whatnowproc,c,'  \
340        'n,-filter,f,'\
341        'n,-form,f,'\
342        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
343
344    complete inc \
345        'c/-/(audit file noaudit nochangecur changecur file form format nosilent silent notruncate truncate width help)/' \
346        'c,+,$folders,'  \
347        'n,-audit,f,'\
348        'n,-form,f,'
349
350    complete mark \
351        'c/-/(add delete list sequence nopublic public nozero zero help)/' \
352        'c,+,$folders,'  \
353        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
354
355    complete mhmail \
356        'c/-/(body cc from subject help)/' \
357        'n,-cc,$mha,'  \
358        'n,-from,$mha,'  \
359        'n/*/$mha/'
360
361    complete mhpath \
362        'c/-/(help)/' \
363        'c,+,$folders,'  \
364        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
365
366    complete msgchk \
367        'c/-/(nodate date nonotify notify help)/' 
368
369    complete msh \
370        'c/-/(prompt noscan scan notopcur topcur help)/' 
371
372    complete next \
373        'c/-/(draft form moreproc nomoreproc length width showproc noshowproc header noheader help)/' \
374        'c,+,$folders,'  \
375        'n,-moreproc,c,'  \
376        'n,-showproc,c,'  \
377        'n,-form,f,'
378
379    complete packf \
380        'c/-/(file help)/' \
381        'c,+,$folders,'  \
382        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
383
384    complete pick \
385        'c/-/(and or not lbrace rbrace cc date from search subject to othercomponent after before datefield sequence nopublic public nozero zero nolist list help)/' \
386        'c,+,$folders,'  \
387        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
388
389    complete prev \
390        'c/-/(draft form moreproc nomoreproc length width showproc noshowproc header noheader help)/' \
391        'c,+,$folders,'  \
392        'n,-moreproc,c,'  \
393        'n,-showproc,c,'  \
394        'n,-form,f,'
395
396    complete prompter \
397        'c/-/(erase kill noprepend prepend norapid rapid nodoteof doteof help)/' 
398
399    complete refile \
400        'c/-/(draft nolink link nopreserve preserve src file help)/' \
401        'c,+,$folders,'  \
402        'n,-file,f,'\
403        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
404
405    complete rmf \
406        'c/-/(nointeractive interactive help)/' \
407        'c,+,$folders,'  
408
409    complete rmm \
410        'c/-/(help)/' \
411        'c,+,$folders,'  \
412        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
413
414    complete scan \
415        'c/-/(noclear clear form format noheader header width noreverse reverse file help)/' \
416        'c,+,$folders,'  \
417        'n,-form,f,'\
418        'n,-file,f,'\
419        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
420
421    complete send \
422        'c/-/(alias draft draftfolder draftmessage nodraftfolder filter nofilter noformat format noforward forward nomsgid msgid nopush push noverbose verbose nowatch watch width help)/' \
423        'n,-alias,f,'\
424        'n,-filter,f,'
425
426    complete show \
427        'c/-/(draft form moreproc nomoreproc length width showproc noshowproc header noheader help)/' \
428        'c,+,$folders,'  \
429        'n,-moreproc,c,'  \
430        'n,-showproc,c,'  \
431        'n,-form,f,'\
432        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
433
434    complete sortm \
435        'c/-/(datefield textfield notextfield limit nolimit noverbose verbose help)/' \
436        'c,+,$folders,'  \
437        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
438
439    complete vmh \
440        'c/-/(prompt vmhproc novmhproc help)/' \
441        'n,-vmhproc,c,'  
442
443    complete whatnow \
444        'c/-/(draftfolder draftmessage nodraftfolder editor noedit prompt help)/' 
445
446    complete whom \
447        'c/-/(alias nocheck check draft draftfolder draftmessage nodraftfolder help)/' \
448        'n,-alias,f,'
449
450    complete plum \
451        'c/-/()/' \
452        'c,+,$folders,'  \
453        'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
454
455    complete mail \
456        'c/-/()/' \
457        'n/*/$mha/'
458
459    endif
460
461    #from Dan Nicolaescu <dann@ics.uci.edu>
462    if ( $?MODULESHOME ) then
463	alias Compl_module 'find ${MODULEPATH:as/:/ /} -name .version -o -name .modulea\* -prune -o -print  | sed `echo "-e s@${MODULEPATH:as%:%/\*@@g -e s@%}/\*@@g"`'
464	complete module 'p%1%(add load unload switch display avail use unuse update purge list clear help initadd initrm initswitch initlist initclear)%' \
465	'n%{unl*,sw*,inits*}%`echo "$LOADEDMODULES:as/:/ /"`%' \
466	'n%{lo*,di*,he*,inita*,initr*}%`eval Compl_module`%' \
467	'N%{sw*,initsw*}%`eval Compl_module`%' 'C%-%(-append)%' 'n%{use,unu*,av*}%d%' 'n%-append%d%' \
468	'C%[^-]*%`eval Compl_module`%'
469    endif
470
471    # from George Cox
472    complete acroread	'p/*/f:*.{pdf,PDF}/'
473    complete apachectl  'c/*/(start stop restart fullstatus status graceful \
474			configtest help)/'
475    complete appletviewer	'p/*/f:*.class/'
476    complete bison	'c/--/(debug defines file-prefix= fixed-output-files \
477			help name-prefix= no-lines no-parser output= \
478			token-table verbose version yacc)/' \
479			'c/-/(b d h k l n o p t v y V)/' 'n/-b/f/' 'n/-o/f/' \
480			'n/-p/f/'
481    complete bzcat	c/--/"(help test quiet verbose license version)"/ \
482			c/-/"(h t L V -)"/ n/*/f:*.{bz2,tbz}/
483    complete bunzip2	c/--/"(help keep force test stdout quiet verbose \
484                        license version)"/ c/-/"(h k f t c q v L V -)"/ \
485			n/*/f:*.{bz2,tbz}/
486    complete bzip2	c/--/"(help decompress compress keep force test \
487			stdout quiet verbose license version small)"/ \
488			c/-/"(h d z k f t c q v L V s 1 2 3 4 5 6 7 8 9 -)"/ \
489			n/{-d,--decompress}/f:*.{bz2,tbz}/ \
490			N/{-d,--decompress}/f:*.{bz2,tbz}/ n/*/f:^*.{bz2,tbz}/
491    complete c++	'p/*/f:*.{c++,cxx,c,cc,C,cpp}/'
492    complete co		'p@1@`\ls -1a RCS | sed -e "s/\(.*\),v/\1/"`@'
493    complete crontab	'n/-u/u/'
494    complete camcontrol	'p/1/(cmd debug defects devlist eject inquiry \
495			modepage negotiate periphlist rescan reset start \
496			stop tags tur)/'
497    complete ctlinnd	'p/1/(addhist allow begin cancel changegroup \
498			checkfile drop feedinfo flush flushlogs go hangup \
499			logmode mode name newgroup param pause readers refile \
500			reject reload renumber reserve rmgroup send shutdown \
501			kill throttle trace xabort xexec)/'
502    complete cvs	'c/--/(help help-commands help-synonyms)/' \
503			'p/1/(add admin annotate checkout commit diff \
504			edit editors export history import init log login \
505			logout rdiff release remove rtag status tag unedit \
506			update watch watchers)/' 'n/-a/(edit unedit commit \
507			all none)/' 'n/watch/(on off add remove)/'
508    complete cxx	'p/*/f:*.{c++,cxx,c,cc,C,cpp}/'
509    complete detex	'p/*/f:*.tex/'
510    complete edquota    'n/*/u/'
511    complete exec	'p/1/c/'
512    complete ghostview	'p/*/f:*.ps/'
513    complete gv		'p/*/f:*.ps/'
514    complete ifconfig	'p@1@`ifconfig -l`@' 'n/*/(range phase link netmask \
515			mtu vlandev vlan metric mediaopt down delete \
516			broadcast arp debug)/'
517    complete imake	'c/-I/d/'
518    complete ipfw 	'p/1/(flush add delete list show zero)/' \
519			'n/add/(allow permit accept pass deny drop reject \
520			reset count skipto num divert port tee port)/'
521    complete javac	'p/*/f:*.java/'
522    complete ldif2ldbm	'n/-i/f:*.ldif/'
523    complete libtool	'c/--mode=/(compile execute finish install link \
524			uninstall)/' 'c/--/(config debug dry-run features \
525			finish help quiet silent version mode=)/'
526    complete libtoolize	'c/--/(automake copy debug dry-run force help ltdl \
527			ltdl-tar version)/'
528    complete links	'c/-/(assume-codepage async-dns download-dir \
529			format-cache-size ftp-proxy help http-proxy \
530			max-connections max-connections-to-host \
531			memory-cache-size receive-timeout retries \
532			unrestartable-receive-timeout version)/'
533    complete natd	c/-/'(alias_address config deny_incoming dynamic \
534			inport interface log log_denied log_facility \
535			outport outport port pptpalias proxy_only \
536			proxy_rule redirect_address redirect_port \
537			reverse same_ports unregistered_only use_sockets \
538			verbose)'/ 'n@-interface@`ifconfig -l`@'
539    complete netstat	'n@-I@`ifconfig -l`@'
540    complete objdump	'c/--/(adjust-vma= all-headers architecture= \
541			archive-headers debugging demangle disassemble \
542			disassemble-all disassemble-zeroes dynamic-reloc \
543			dynamic-syms endian= file-headers full-contents \
544			headers help info line-numbers no-show-raw-insn \
545			prefix-addresses private-headers reloc section-headers \
546			section=source stabs start-address= stop-address= \
547			syms target= version wide)/' \
548			'c/-/(a h i f C d D p r R t T x s S l w)/'
549    complete xmodmap	'c/-/(display help grammar verbose quiet n e pm pk \
550			pke pp)/'
551    complete lynx	'c/-/(accept_all_cookies anonymous assume_charset= \
552			assume_local_charset= assume_unrec_charset= auth= base \
553			book buried_news cache= case cfg= child cookie_file= \
554			cookies core crawl debug_partial display= dump editor= \
555			emacskeys enable_scrollback error_file= force_html \
556			force_secure forms_options from ftp get_data head help \
557			hiddenlinks= historical homepage= image_links index= \
558			ismap link= localhost mime_header minimal \
559			newschunksize= newsmaxchunk= nobrowse nocc nocolor \
560			nofilereferer nolist nolog nopause noprint noredir \
561			noreferer nostatus number_links partial partial_thres \
562			pauth= popup post_data preparsed print pseudo_inlines \
563			raw realm reload restrictions= resubmit_posts rlogin \
564			selective show_cursor soft_dquotes source stack_dump \
565			startfile_ok tagsoup telnet term= tlog trace traversal \
566			underscore useragent= validate verbose version vikeys \
567			width=)/' 'c/(http|ftp)/$URLS/'
568    complete gmake	'c/{--directory=,--include-dir=}/d/' \
569			'c/{--assume-new,--assume-old,--makefile,--new-file,--what-if,--file}/f/' \
570			'c/--/(assume-new= assume-old= debug directory= \
571			dry-run environment-overrides file= help \
572			ignore-errors include-dir= jobs[=N] just-print \
573			keep-going load-average[=N] makefile= max-load[=N] \
574			new-file= no-builtin-rules no-keep-going \
575			no-print-directory old-file= print-data-base \
576			print-directory question quiet recon silent stop \
577			touch version warn-undefined-variables what-if=)/' \
578			'n@*@`cat -s GNUMakefile Makefile makefile |& sed -n -e "/No such file/d" -e "s/^\([A-Za-z0-9-]*\):.*/\1/p"`@' \
579			'n/=/f/' 'n/-f/f/'
580    complete mixer	p/1/'(vol bass treble synth pcm speaker mic cd mix \
581			pcm2 rec igain ogain line1 line2 line3)'/ \
582			p@2@'`mixer $:-1 | awk \{\ print\ \$7\ \}`'@
583
584    complete mpg123	'c/--/(2to1 4to1 8bit aggressive au audiodevice \
585    			auth buffer cdr check doublespeed equalizer frames \
586			gain halfspeed headphones left lineout list mix mono \
587			proxy quiet random rate reopen resync right scale \
588			shuffle single0 single1 skip speaker stdout stereo \
589			test verbose wav)/'
590    complete mysqladmin	'n/*/(create drop extended-status flush-hosts \
591			flush-logs flush-status flush-tables flush-privileges \
592			kill password ping processlist reload refresh \
593			shutdown status variables version)/'
594    complete mutt	c@-f=@F:${HOME}/Mail/@ \
595			n/-a/f/ \
596			n/-F/f/ n/-H/f/ \
597			n/-s/x:'<subject line>'/ \
598			n/-e/x:'<command>'/ \
599			n@-b@'`cat ${HOME}/.muttrc-alias | awk '"'"'{print $2 }'"'"\`@ \
600			n@-c@'`cat ${HOME}/.muttrc-alias | awk '"'"'{print $2 }'"'"\`@ \
601			n@*@'`cat ${HOME}/.muttrc-alias | awk '"'"'{print $2 }'"'"\`@
602    complete ndc	'n/*/(status dumpdb reload stats trace notrace \
603			querylog start stop restart )/'
604    if ($?traditional_complete) then
605        complete nm \
606		'c/--/(debug-syms defined-only demangle dynamic \
607			extern-only format= help line-numbers no-demangle \
608			no-sort numeric-sort portability print-armap \
609			print-file-name reverse-sort size-sort undefined-only \
610			version)/' 'p/*/f:^*.{h,C,c,cc}/'
611    else
612	complete nm \
613		'c/--radix=/x:<radix: _o_ctal _d_ecimal he_x_adecimal>/' \
614		'c/--target=/x:<bfdname>/' \
615		'c/--format=/(bsd sysv posix)/n/' \
616		'c/--/(debugsyms extern-only demangle dynamic print-armap \
617			print-file-name numeric-sort no-sort reverse-sort \
618			size-sort undefined-only portability target= radix= \
619			format= defined-only\ line-numbers no-demangle version \
620			help)//' \
621		'n/*/f:^*.{h,c,cc,s,S}/'
622    endif
623    complete nmap	'n@-e@`ifconfig -l`@' 'p/*/$hostnames/'
624    complete perldoc 	'n@*@`\ls -1 /usr/libdata/perl/5.*/pod | sed s%\\.pod.\*\$%%`@'
625    complete postfix    'n/*/(start stop reload abort flush check)/'
626    complete postmap	'n/1/(hash: regexp:)' 'c/hash:/f/' 'c/regexp:/f/'
627    complete rcsdiff	'p@1@`\ls -1a RCS | sed -e "s/\(.*\),v/\1/"`@'
628    complete X		'c/-/(I a ac allowMouseOpenFail allowNonLocalModInDev \
629			allowNonLocalXvidtune ar1 ar2 audit auth bestRefresh \
630			bgamma bpp broadcast bs c cc class co core deferglyphs \
631			disableModInDev disableVidMode displayID dpi dpms f fc \
632			flipPixels fn fp gamma ggamma help indirect kb keeptty \
633			ld lf logo ls nolisten string noloadxkb nolock nopn \
634			once p pn port probeonly query quiet r rgamma s \
635			showconfig sp su t terminate to tst v verbose version \
636			weight wm x xkbdb xkbmap)/'
637    complete users      'c/--/(help version)/' 'p/1/x:"<accounting_file>"/'
638    complete vidcontrol	'p/1/(132x25 132x30 132x43 132x50 132x60 40x25 80x25 \
639			80x30 80x43 80x50 80x60 EGA_80x25 EGA_80x43 \
640			VESA_132x25 VESA_132x30 VESA_132x43 VESA_132x50 \
641			VESA_132x60 VESA_800x600 VGA_320x200 VGA_40x25 \
642			VGA_80x25 VGA_80x30 VGA_80x50 VGA_80x60)/'
643    complete vim	'n/*/f:^*.[oa]/'
644    complete where	'n/*/c/'
645    complete which	'n/*/c/'
646    complete wmsetbg	'c/-/(display D S a b c d e m p s t u w)/' \
647			'c/--/(back-color center colors dither help match \
648			maxscale parse scale smooth tile update-domain \
649			update-wmaker version workspace)/'
650    complete xdb	'p/1/c/'
651    complete xdvi	'c/-/(allowshell debug display expert gamma hushchars \
652			hushchecksums hushspecials install interpreter keep \
653			margins nogrey noinstall nomakepk noscan paper safer \
654			shrinkbuttonn thorough topmargin underlink version)/' \
655			'n/-paper/(a4 a4r a5 a5r)/' 'p/*/f:*.dvi/'
656    complete xlock	'c/-/(allowaccess allowroot debug description \
657			echokeys enablesaver grabmouse grabserver hide inroot \
658			install inwindow mono mousemotion nolock remote \
659			resetsaver sound timeelapsed use3d usefirst verbose \
660			wireframe background batchcount bg bitmap both3d \
661			count cycles delay delta3d display dpmsoff \
662			dpmsstandby dpmssuspend endCmd erasedelay erasemode \
663			erasetime fg font foreground geometry help \
664			icongeometry info invalid left3d lockdelay logoutCmd \
665			mailCmd mailIcon message messagefile messagefont \
666			messagesfile mode name ncolors nice nomailIcon none3d \
667			parent password planfont program resources right3d \
668			saturation size startCmd timeout username validate \
669			version visual)/' 'n/-mode/(ant atlantis ball bat \
670			blot bouboule bounce braid bubble bubble3d bug cage \
671			cartoon clock coral crystal daisy dclock decay deco \
672			demon dilemma discrete drift eyes fadeplot flag flame \
673			flow forest galaxy gears goop grav helix hop hyper \
674			ico ifs image invert julia kaleid kumppa lament laser \
675			life life1d life3d lightning lisa lissie loop lyapunov \
676			mandelbrot marquee matrix maze moebius morph3d \
677			mountain munch nose pacman penrose petal pipes puzzle \
678			pyro qix roll rotor rubik shape sierpinski slip sphere \
679			spiral spline sproingies stairs star starfish strange \
680			superquadrics swarm swirl tetris thornbird triangle \
681			tube turtle vines voters wator wire world worm xjack \
682			blank bomb random)/' 
683    complete xfig	'c/-/(display)/' 'p/*/f:*.fig/'
684    complete wget 	c/--/"(accept= append-output= background cache= \
685			continue convert-links cut-dirs= debug \
686			delete-after directory-prefix= domains= \
687			dont-remove-listing dot-style= exclude-directories= \
688			exclude-domains= execute= follow-ftp \
689			force-directories force-html glob= header= help \
690			http-passwd= http-user= ignore-length \
691			include-directories= input-file= level= mirror \
692			no-clobber no-directories no-host-directories \
693			no-host-lookup no-parent non-verbose \
694			output-document= output-file= passive-ftp \
695			proxy-passwd= proxy-user= proxy= quiet quota= \
696			recursive reject= relative retr-symlinks save-headers \
697			server-response span-hosts spider timeout= \
698			timestamping tries= user-agent= verbose version wait=)"/
699
700    # these from Tom Warzeka <tom@waz.cc>
701
702    # this one works but is slow and doesn't descend into subdirectories
703    # complete	cd	C@[./\$~]*@d@ \
704    #			p@1@'`\ls -1F . $cdpath | grep /\$ | sort -u`'@ n@*@n@
705
706    if ( -r /etc/shells ) then
707        complete setenv	p@1@e@ n@DISPLAY@\$hosts@: n@SHELL@'`cat /etc/shells`'@
708    else
709	complete setenv	p@1@e@ n@DISPLAY@\$hosts@:
710    endif
711    complete unsetenv	n/*/e/
712
713    set _maildir = /var/mail
714    if (-r $HOME/.mailrc) then
715        complete mail	c/-/"(e i f n s u v)"/ c/*@/\$hosts/ \
716			c@+@F:$HOME/Mail@ C@[./\$~]@f@ n/-s/x:'<subject>'/ \
717			n@-u@T:$_maildir@ n/-f/f/ \
718			n@*@'`sed -n s/alias//p $HOME/.mailrc | tr -s " " "	" | cut -f 2`'@
719    else
720        complete mail	c/-/"(e i f n s u v)"/ c/*@/\$hosts/ \
721			c@+@F:$HOME/Mail@ C@[./\$~]@f@ n/-s/x:'<subject>'/ \
722			n@-u@T:$_maildir@ n/-f/f/ n/*/u/
723    endif
724    unset _maildir
725
726    if (! $?MANPATH) then
727	if (-r /usr/share/man) then
728	    setenv MANPATH /usr/share/man:
729	else
730	    setenv MANPATH /usr/man:
731	endif
732    endif
733
734    if ($?traditional_complete) then
735        # use of $MANPATH from Dan Nicolaescu <dann@ics.uci.edu>
736        # use of 'find' adapted from Lubomir Host <host8@kepler.fmph.uniba.sk>
737        complete man \
738	    'n@1@`set q = "$MANPATH:as%:%/man1 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.1.\*\$%%`@'\
739	    'n@2@`set q = "$MANPATH:as%:%/man2 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.2.\*\$%%`@'\
740	    'n@3@`set q = "$MANPATH:as%:%/man3 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.3.\*\$%%`@'\
741	    'n@4@`set q = "$MANPATH:as%:%/man4 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.4.\*\$%%`@'\
742	    'n@5@`set q = "$MANPATH:as%:%/man5 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.5.\*\$%%`@'\
743	    'n@6@`set q = "$MANPATH:as%:%/man6 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.6.\*\$%%`@'\
744	    'n@7@`set q = "$MANPATH:as%:%/man7 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.7.\*\$%%`@'\
745	    'n@8@`set q = "$MANPATH:as%:%/man8 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.8.\*\$%%`@'\
746	    'n@9@`set q = "$MANPATH:as%:%/man9 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.9.\*\$%%`@'\
747	    'n@0@`set q = "$MANPATH:as%:%/man0 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.0.\*\$%%`@'\
748	    'n@n@`set q = "$MANPATH:as%:%/mann %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.n.\*\$%%`@'\
749	    'n@o@`set q = "$MANPATH:as%:%/mano %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.o.\*\$%%`@'\
750	    'n@l@`set q = "$MANPATH:as%:%/manl %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.l.\*\$%%`@'\
751	    'n@p@`set q = "$MANPATH:as%:%/manp %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.p.\*\$%%`@'\
752	    c@-@"(- f k M P s S t)"@ n@-f@c@ n@-k@x:'<keyword>'@ n@-[MP]@d@   \
753	    'N@-[MP]@`\ls -1 $:-1/man? |& sed -n s%\\..\\+\$%%p`@'            \
754	    'n@-[sS]@`\ls -1 $MANPATH:as%:% % |& sed -n s%^man%%p | sort -u`@'\
755	    'n@*@`find $MANPATH:as%:% % \( -type f -o -type l \) -printf "%f " |& sed -e "s%find: .*: No such file or directory%%" -e "s%\([^\.]\+\)\.\([^ ]*\) %\1 %g"`@'
756	    #n@*@c@ # old way -- commands only
757    else
758        complete man	    n@1@'`\ls -1 /usr/man/man1 | sed s%\\.1.\*\$%%`'@ \
759			    n@2@'`\ls -1 /usr/man/man2 | sed s%\\.2.\*\$%%`'@ \
760			    n@3@'`\ls -1 /usr/man/man3 | sed s%\\.3.\*\$%%`'@ \
761			    n@4@'`\ls -1 /usr/man/man4 | sed s%\\.4.\*\$%%`'@ \
762			    n@5@'`\ls -1 /usr/man/man5 | sed s%\\.5.\*\$%%`'@ \
763			    n@6@'`\ls -1 /usr/man/man6 | sed s%\\.6.\*\$%%`'@ \
764			    n@7@'`\ls -1 /usr/man/man7 | sed s%\\.7.\*\$%%`'@ \
765			    n@8@'`\ls -1 /usr/man/man8 | sed s%\\.8.\*\$%%`'@ \
766    n@9@'`[ -r /usr/man/man9 ] && \ls -1 /usr/man/man9 | sed s%\\.9.\*\$%%`'@ \
767    n@0@'`[ -r /usr/man/man0 ] && \ls -1 /usr/man/man0 | sed s%\\.0.\*\$%%`'@ \
768  n@new@'`[ -r /usr/man/mann ] && \ls -1 /usr/man/mann | sed s%\\.n.\*\$%%`'@ \
769  n@old@'`[ -r /usr/man/mano ] && \ls -1 /usr/man/mano | sed s%\\.o.\*\$%%`'@ \
770n@local@'`[ -r /usr/man/manl ] && \ls -1 /usr/man/manl | sed s%\\.l.\*\$%%`'@ \
771n@public@'`[ -r /usr/man/manp ]&& \ls -1 /usr/man/manp | sed s%\\.p.\*\$%%`'@ \
772		c/-/"(- f k P s t)"/ n/-f/c/ n/-k/x:'<keyword>'/ n/-P/d/ \
773		N@-P@'`\ls -1 $:-1/man? | sed s%\\..\*\$%%`'@ n/*/c/
774    endif
775
776    complete ps	        c/-t/x:'<tty>'/ c/-/"(a c C e g k l S t u v w x)"/ \
777			n/-k/x:'<kernel>'/ N/-k/x:'<core_file>'/ n/*/x:'<PID>'/
778    complete compress	c/-/"(c f v b)"/ n/-b/x:'<max_bits>'/ n/*/f:^*.Z/
779    complete uncompress	c/-/"(c f v)"/                        n/*/f:*.Z/
780
781    complete uuencode	p/1/f/ p/2/x:'<decode_pathname>'/ n/*/n/
782    complete uudecode	c/-/"(f)"/ n/-f/f:*.{uu,UU}/ p/1/f:*.{uu,UU}/ n/*/n/
783
784    complete xhost	c/[+-]/\$hosts/ n/*/\$hosts/
785    complete xpdf	c/-/"(z g remote raise quit cmap rgb papercolor       \
786			      eucjp t1lib freetype ps paperw paperh level1    \
787			      upw fullscreen cmd q v h help)"/                \
788			n/-z/x:'<zoom (-5 .. +5) or "page" or "width">'/      \
789			n/-g/x:'<geometry>'/ n/-remote/x:'<name>'/            \
790			n/-rgb/x:'<number>'/ n/-papercolor/x:'<color>'/       \
791			n/-{t1lib,freetype}/x:'<font_type>'/                  \
792			n/-ps/x:'<PS_file>'/ n/-paperw/x:'<width>'/           \
793			n/-paperh/x:'<height>'/ n/-upw/x:'<password>'/        \
794			n/-/f:*.{pdf,PDF}/                                    \
795			N/-{z,g,remote,rgb,papercolor,t1lib,freetype,ps,paperw,paperh,upw}/f:*.{pdf,PDF}/ \
796			N/-/x:'<page>'/ p/1/f:*.{pdf,PDF}/ p/2/x:'<page>'/
797
798    complete tcsh	c/-D*=/'x:<value>'/ c/-D/'x:<name>'/ \
799			c/-/"(b c d D e f F i l m n q s t v V x X -version)"/ \
800			n/-c/c/ n/{-l,--version}/n/ n/*/'f:*.{,t}csh'/
801
802    complete rpm	c/--/"(query verify nodeps nofiles nomd5 noscripts    \
803	                nogpg nopgp install upgrade freshen erase allmatches  \
804		        notriggers repackage test rebuild recompile initdb    \
805		        rebuilddb addsign resign querytags showrc setperms    \
806		        setugids all file group package querybynumber qf      \
807		        triggeredby whatprovides whatrequires changelog       \
808		        configfiles docfiles dump filesbypkg info last list   \
809		        provides queryformat requires scripts state triggers  \
810		        triggerscripts allfiles badreloc excludepath checksig \
811	                excludedocs force hash ignoresize ignorearch ignoreos \
812		        includedocs justdb noorder oldpackage percent prefix  \
813		        relocate replace-files replacepkgs buildroot clean    \
814		        nobuild rmsource rmspec short-circuit sign target     \
815		        help version quiet rcfile pipe dbpath root specfile)"/\
816		        c/-/"(q V K i U F e ba bb bp bc bi bl bs ta tb tp tc  \
817			ti tl ts a f g p c d l R s h ? v vv -)"/              \
818		n/{-f,--file}/f/ n/{-g,--group}/g/ n/--pipe/c/ n/--dbpath/d/  \
819		n/--querybynumber/x:'<number>'/ n/--triggeredby/x:'<package>'/\
820		n/--what{provides,requires}/x:'<capability>'/ n/--root/d/     \
821		n/--{qf,queryformat}/x:'<format>'/ n/--buildroot/d/           \
822		n/--excludepath/x:'<oldpath>'/  n/--prefix/x:'<newpath>'/     \
823		n/--relocate/x:'<oldpath=newpath>'/ n/--target/x:'<platform>'/\
824		n/--rcfile/x:'<filelist>'/ n/--specfile/x:'<specfile>'/       \
825	        n/{-[iUFep],--{install,upgrade,freshen,erase,package}}/f:*.rpm/
826
827    # these conform to the latest GNU versions available at press time ...
828    # updates by John Gotts <jgotts@engin.umich.edu>
829    if (-X emacs) then
830      # TW note:  if your version of GNU Emacs supports the "--version" option,
831      #           uncomment this line and comment the next to automatically
832      #           detect the version, else set "_emacs_ver" to your version.
833      #set _emacs_ver=`emacs --version | sed -e 's%GNU Emacs %%' -e q | cut -d . -f1-2`
834      set _emacs_ver=21.3
835      set _emacs_dir=`which emacs | sed s%/bin/emacs%%` 
836      complete emacs	c/--/"(batch terminal display no-windows no-init-file \
837                               user debug-init unibyte multibyte version help \
838                               no-site-file funcall load eval insert kill)"/ \
839                        c/-/"(t d nw q u f l -)"/ c/+/x:'<line_number>'/ \
840			n/{-t,--terminal}/x:'<terminal>'/ n/{-d,--display}/x:'<display>'/ \
841	                n/{-u,--user}/u/ n/{-f,--funcall}/x:'<lisp_function>'/ \
842			n@{-l,--load}@F:$_emacs_dir/share/emacs/$_emacs_ver/lisp@ \
843			n/--eval/x:'<expression>'/ n/--insert/f/ n/*/f:^*[\#~]/
844      unset _emacs_ver _emacs_dir
845    endif
846
847    complete gzcat	c/--/"(force help license quiet version)"/ \
848			c/-/"(f h L q V -)"/ n/*/f:*.{gz,Z,z,zip}/
849    complete gzip	c/--/"(stdout to-stdout decompress uncompress \
850			force help list license no-name quiet recurse \
851			suffix test verbose version fast best)"/ \
852			c/-/"(c d f h l L n q r S t v V 1 2 3 4 5 6 7 8 9 -)"/\
853			n/{-S,--suffix}/x:'<file_name_suffix>'/ \
854			n/{-d,--{de,un}compress}/f:*.{gz,Z,z,zip,taz,tgz}/ \
855			N/{-d,--{de,un}compress}/f:*.{gz,Z,z,zip,taz,tgz}/ \
856			n/*/f:^*.{gz,Z,z,zip,taz,tgz}/
857    complete {gunzip,ungzip} c/--/"(stdout to-stdout force help list license \
858			no-name quiet recurse suffix test verbose version)"/ \
859			c/-/"(c f h l L n q r S t v V -)"/ \
860			n/{-S,--suffix}/x:'<file_name_suffix>'/ \
861			n/*/f:*.{gz,Z,z,zip,taz,tgz}/
862    complete zgrep	c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
863			c/-/"(A b B c C e f h i l n s v V w x)"/ \
864			p/1/x:'<limited_regular_expression>'/ N/-*e/f/ \
865			n/-*e/x:'<limited_regular_expression>'/ n/-*f/f/ n/*/f/
866    complete zegrep	c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
867			c/-/"(A b B c C e f h i l n s v V w x)"/ \
868			p/1/x:'<full_regular_expression>'/ N/-*e/f/ \
869			n/-*e/x:'<full_regular_expression>'/ n/-*f/f/ n/*/f/
870    complete zfgrep	c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
871			c/-/"(A b B c C e f h i l n s v V w x)"/ \
872			p/1/x:'<fixed_string>'/ N/-*e/f/ \
873			n/-*e/x:'<fixed_string>'/ n/-*f/f/ n/*/f/
874    complete znew	c/-/"(f t v 9 P K)"/ n/*/f:*.Z/
875    complete zmore	n/*/f:*.{gz,Z,z,zip}/
876    complete zfile	n/*/f:*.{gz,Z,z,zip,taz,tgz}/
877    complete ztouch	n/*/f:*.{gz,Z,z,zip,taz,tgz}/
878    complete zforce	n/*/f:^*.{gz,tgz}/
879
880    complete dcop 'p/1/`$:0`/ /' \
881	'p/2/`$:0 $:1 | awk \{print\ \$1\}`/ /' \
882	'p/3/`$:0 $:1 $:2 | sed "s%.* \(.*\)(.*%\1%"`/ /'
883
884
885    complete grep	c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
886			c/--/"(extended-regexp fixed-regexp basic-regexp \
887			regexp file ignore-case word-regexp line-regexp \
888			no-messages revert-match version help byte-offset \
889			line-number with-filename no-filename quiet silent \
890			text directories recursive files-without-match \
891			files-with-matches count before-context after-context \
892			context binary unix-byte-offsets)"/ \
893			c/-/"(A a B b C c d E e F f G H h i L l n q r s U u V \
894				v w x)"/ \
895			p/1/x:'<limited_regular_expression>'/ N/-*e/f/ \
896			n/-*e/x:'<limited_regular_expression>'/ n/-*f/f/ n/*/f/
897    complete egrep	c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
898			c/--/"(extended-regexp fixed-regexp basic-regexp \
899			regexp file ignore-case word-regexp line-regexp \
900			no-messages revert-match version help byte-offset \
901			line-number with-filename no-filename quiet silent \
902			text directories recursive files-without-match \
903			files-with-matches count before-context after-context \
904			context binary unix-byte-offsets)"/ \
905			c/-/"(A a B b C c d E e F f G H h i L l n q r s U u V \
906				v w x)"/ \
907			p/1/x:'<full_regular_expression>'/ N/-*e/f/ \
908			n/-*e/x:'<full_regular_expression>'/ n/-*f/f/ n/*/f/
909    complete fgrep	c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
910			c/--/"(extended-regexp fixed-regexp basic-regexp \
911			regexp file ignore-case word-regexp line-regexp \
912			no-messages revert-match version help byte-offset \
913			line-number with-filename no-filename quiet silent \
914			text directories recursive files-without-match \
915			files-with-matches count before-context after-context \
916			context binary unix-byte-offsets)"/ \
917			c/-/"(A a B b C c d E e F f G H h i L l n q r s U u V \
918				v w x)"/ \
919			p/1/x:'<fixed_string>'/ N/-*e/f/ \
920			n/-*e/x:'<fixed_string>'/ n/-*f/f/ n/*/f/
921
922    complete sed	c/--/"(quiet silent version help expression file)"/   \
923			c/-/"(n V e f -)"/ n/{-e,--expression}/x:'<script>'/  \
924			n/{-f,--file}/f:*.sed/ N/-{e,f,-{file,expression}}/f/ \
925			n/-/x:'<script>'/ N/-/f/ p/1/x:'<script>'/ p/2/f/
926
927    complete users	c/--/"(help version)"/ p/1/x:'<accounting_file>'/
928    complete who	c/--/"(heading idle count mesg message writable help \
929    			version)"/ c/-/"(H i m q s T w u -)"/ \
930			p/1/x:'<accounting_file>'/ n/am/"(i)"/ n/are/"(you)"/
931
932    complete chown	c/--/"(changes dereference no-dereference silent \
933    			quiet reference recursive verbose help version)"/ \
934			c/-/"(c f h R v -)"/ C@[./\$~]@f@ c/*[.:]/g/ \
935			n/-/u/: p/1/u/: n/*/f/
936    complete chgrp	c/--/"(changes no-dereference silent quiet reference \
937    			recursive verbose help version)"/ \
938			c/-/"(c f h R v -)"/ n/-/g/ p/1/g/ n/*/f/
939    complete chmod	c/--/"(changes silent quiet verbose reference \
940    			recursive help version)"/ c/-/"(c f R v)"/
941    complete df		c/--/"(all block-size human-readable si inodes \
942			kilobytes local megabytes no-sync portability sync \
943			type print-type exclude-type help version)"/ \
944			c/-/"(a H h i k l m P T t v x)"/
945    complete du		c/--/"(all block-size bytes total dereference-args \
946    			human-readable si kilobytes count-links dereference \
947			megabytes separate-dirs summarize one-file-system \
948			exclude-from exclude max-depth help version"/ \
949			c/-/"(a b c D H h k L l m S s X x)"/
950
951    complete cat	c/--/"(number-nonblank number squeeze-blank show-all \
952			show-nonprinting show-ends show-tabs help version)"/ \
953			c/-/"(A b E e n s T t u v -)"/ n/*/f/
954    complete mv		c/--/"(backup force interactive update verbose suffix \
955			version-control help version)"/ \
956			c/-/"(b f i S u V v -)"/ \
957			n/{-S,--suffix}/x:'<suffix>'/ \
958			n/{-V,--version-control}/"(t numbered nil existing \
959			never simple)"/ n/-/f/ N/-/d/ p/1/f/ p/2/d/ n/*/f/
960    complete cp		c/--/"(archive backup no-dereference force \
961    			interactive link preserve parents sparse recursive \
962			symbolic-link suffix update verbose version-control \
963			one-file-system help version)"/ \
964			c/-/"(a b d f i l P p R r S s u V v x -)"/ \
965			n/-*r/d/ n/{-S,--suffix}/x:'<suffix>'/ \
966			n/{-V,--version-control}/"(t numbered nil existing \
967			never simple)"/ n/-/f/ N/-/d/ p/1/f/ p/2/d/ n/*/f/
968    complete ln		c/--/"(backup directory force no-dereference \
969    			interactive symbolic suffix verbose version-control \
970			help version)"/ \
971			c/-/"(b d F f i n S s V v -)"/ \
972			n/{-S,--suffix}/x:'<suffix>'/ \
973			n/{-V,--version-control}/"(t numbered nil existing \
974			never simple)"/ n/-/f/ N/-/x:'<link_name>'/ \
975			p/1/f/ p/2/x:'<link_name>'/
976    complete touch	c/--/"(date reference time help version)"/ \
977			c/-/"(a c d f m r t -)"/ \
978			n/{-d,--date}/x:'<date_string>'/ \
979			c/--time/"(access atime mtime modify use)"/ \
980			n/{-r,--file}/f/ n/-t/x:'<time_stamp>'/ n/*/f/
981    complete mkdir	c/--/"(mode parents verbose help version)"/ \
982    			c/-/"(p m -)"/ \
983			n/{-m,--mode}/x:'<mode>'/ n/*/d/
984    complete rmdir	c/--/"(ignore-fail-on-non-empty parents verbose help \
985    			version)"/ c/-/"(p -)"/ n/*/d/
986    complete env 	'c/*=/f/' 'p/1/e/=/' 'p/2/c/'
987
988    complete tar	c/-[Acru]*/"(b B C f F g G h i l L M N o P \
989			R S T v V w W X z Z)"/ \
990			c/-[dtx]*/"( B C f F g G i k K m M O p P \
991			R s S T v w x X z Z)"/ \
992			p/1/"(A c d r t u x -A -c -d -r -t -u -x \
993			--catenate --concatenate --create --diff --compare \
994			--delete --append --list --update --extract --get \
995			--help --version)"/ \
996			c/--/"(catenate concatenate create diff compare \
997			delete append list update extract get atime-preserve \
998			block-size read-full-blocks directory checkpoint file \
999			force-local info-script new-volume-script incremental \
1000			listed-incremental dereference ignore-zeros \
1001			ignore-failed-read keep-old-files starting-file \
1002			one-file-system tape-length modification-time \
1003			multi-volume after-date newer old-archive portability \
1004			to-stdout same-permissions preserve-permissions \
1005			absolute-paths preserve record-number remove-files \
1006			same-order preserve-order same-owner sparse \
1007			files-from null totals verbose label version \
1008			interactive confirmation verify exclude exclude-from \
1009			compress uncompress gzip ungzip use-compress-program \
1010			block-compress help version)"/ \
1011			c/-/"(b B C f F g G h i k K l L m M N o O p P R s S \
1012			T v V w W X z Z 0 1 2 3 4 5 6 7 -)"/ \
1013			C@/dev@f@ \
1014			n/-c*f/x:'<new_tar_file, device_file, or "-">'/ \
1015			n/{-[Adrtux]j*f,--file}/f:*.{tar.bz2,tbz}/ \
1016			n/{-[Adrtux]z*f,--file}/f:*.{tar.gz,tgz}/ \
1017			n/{-[Adrtux]Z*f,--file}/f:*.{tar.Z,taz}/ \
1018			n/{-[Adrtux]*f,--file}/f:*.tar/ \
1019			N/{-xj*f,--file}/'`tar -tjf $:-1`'/ \
1020			N/{-xz*f,--file}/'`tar -tzf $:-1`'/ \
1021			N/{-xZ*f,--file}/'`tar -tZf $:-1`'/ \
1022			N/{-x*f,--file}/'`tar -tf $:-1`'/ \
1023			n/--use-compress-program/c/ \
1024			n/{-b,--block-size}/x:'<block_size>'/ \
1025			n/{-V,--label}/x:'<volume_label>'/ \
1026			n/{-N,--{after-date,newer}}/x:'<date>'/ \
1027			n/{-L,--tape-length}/x:'<tape_length_in_kB>'/ \
1028			n/{-C,--directory}/d/ \
1029			N/{-C,--directory}/'`\ls $:-1`'/ \
1030			n/-[0-7]/"(l m h)"/
1031
1032    # Linux filesystems
1033    complete  mount	c/-/"(a f F h l n o r s t U v V w)"/ n/-[hV]/n/ \
1034    			n/-o/x:'<options>'/ n/-t/x:'<vfstype>'/ \
1035    			n/-L/x:'<label>'/ n/-U/x:'<uuid>'/ \
1036    			n@*@'`grep -v "^#" /etc/fstab | tr -s " " "	 " | cut -f 2`'@
1037    complete umount	c/-/"(a h n r t v V)"/ n/-t/x:'<vfstype>'/ \
1038    			n/*/'`mount | cut -d " " -f 3`'/
1039    # Solaris filesystems
1040    #complete  mount	c/-/"(a F m o O p r v V)"/ n/-p/n/ n/-v/n/ \
1041    #			n/-o/x:'<FSType_options>'/ \
1042    #			n@-F@'`\ls -1 /usr/lib/fs`'@ \
1043    #			n@*@'`grep -v "^#" /etc/vfstab | tr -s " " "	 " | cut -f 3`'@
1044    #complete umount	c/-/"(a o V)"/ n/-o/x:'<FSType_options>'/ \
1045    #			n/*/'`mount | cut -d " " -f 1`'/
1046    #complete  mountall	c/-/"(F l r)"/ n@-F@'`\ls -1 /usr/lib/fs`'@
1047    #complete umountall	c/-/"(F h k l r s)"/ n@-F@'`\ls -1 /usr/lib/fs`'@ \
1048    #			n/-h/'`df -k | cut -s -d ":" -f 1 | sort -u`'/
1049
1050    # these deal with NIS (formerly YP); if it's not running you don't need 'em
1051    if (-X domainname) then
1052      set _domain = "`domainname`"
1053      set _ypdir  = /var/yp	# directory where NIS (YP) maps are kept
1054      if ("$_domain" != "" && "$_domain" != "noname") then
1055        complete domainname p@1@D:$_ypdir@" " n@*@n@
1056        complete ypcat	    c@-@"(d k t x)"@ n@-x@n@ n@-d@D:$_ypdir@" " \
1057	                    N@-d@\`\\ls\ -1\ $_ypdir/\$:-1\ \|\ sed\ -n\ s%\\\\.pag\\\$%%p\`@ \
1058	                    n@*@\`\\ls\ -1\ $_ypdir/$_domain\ \|\ sed\ -n\ s%\\\\.pag\\\$%%p\`@
1059        complete ypmatch    c@-@"(d k t x)"@ n@-x@n@ n@-d@D:$_ypdir@" " \
1060	                    N@-d@x:'<key ...>'@ n@-@x:'<key ...>'@ p@1@x:'<key ...>'@ \
1061	                    n@*@\`\\ls\ -1\ $_ypdir/$_domain\ \|\ sed\ -n\ s%\\\\.pag\\\$%%p\`@
1062        complete ypwhich    c@-@"(d m t x V1 V2)"@ n@-x@n@ n@-d@D:$_ypdir@" " \
1063	                    n@-m@\`\\ls\ -1\ $_ypdir/$_domain\ \|\ sed\ -n\ s%\\\\.pag\\\$%%p\`@ \
1064			    N@-m@n@ n@*@\$hosts@
1065      endif
1066      unset _domain _ypdir
1067    endif
1068
1069    complete make \
1070	'n/-f/f/' \
1071      	'c/*=/f/' \
1072	'n@*@`cat -s GNUmakefile Makefile makefile |& sed -n -e "/No such file/d" -e "/^[^     #].*:/s/:.*//p"`@'
1073
1074    if ( -f /etc/printcap ) then
1075	set printers=(`sed -n -e "/^[^     #].*:/s/:.*//p" /etc/printcap`)
1076
1077	complete lpr    'c/-P/$printers/'
1078	complete lpq    'c/-P/$printers/'
1079	complete lprm   'c/-P/$printers/'
1080	complete lpquota        'p/1/(-Qprlogger)/' 'c/-P/$printers/'
1081	complete dvips  'c/-P/$printers/' 'n/-o/f:*.{ps,PS}/' 'n/*/f:*.dvi/'
1082	complete dvilj	'p/*/f:*.dvi/'
1083    endif
1084
1085    # From Alphonse Bendt
1086    complete ant \
1087	 'n/-f/f:*.xml/' \
1088	      'n@*@`cat build.xml | sed -n -e "s/[ \t]*<target[\t\n]*name=.\([a-zA-Z0-9_:]*\).*/\1/p"`@'
1089
1090    if ($?P4CLIENT && -X perl) then
1091	# This is from Greg Allen.
1092	set p4cmds=(add branch branches commands change changes client clients \
1093	    counter counters delete depot depots describe diff diff2 \
1094	    edit filelog files fix fixes fstat group groups have help \
1095	    info integrate integrated job jobs jobspec label labels \
1096	    labelsync lock obliterate opened passwd print protect rename \
1097	    reopen resolve resolved revert review reviews set submit \
1098	    sync triggers unlock user users verify where)
1099	complete p4 'p/1/$p4cmds/' 'n/help/$p4cmds/' \
1100	    'n%{-l,label}%`p4 labels | sed "s/Label \([^ ]*\) .*/\1/"`%' \
1101	    'n%-t%`p4 $:1s | sed "s/[^ ]* \([^ ]*\) .*/\1/"`%' \
1102	    'c%*@%`p4 labels | sed "s/Label \([^ ]*\) .*/\1/"`%' \
1103	    'c@//*/*@`p4 files $:-0... |& perl -nle "m%\Q$:-0\E([^#][^/# ] \
1104	    *)%;print "\$"1 if \\\!/no such/&&\!"\$"h{"\$"1}++"`@@' \
1105	    'c@//@`p4 depots | sed "s/Depot \([^ ]*\) .*/\1/"`@/@'
1106    endif
1107
1108
1109    if (! $?traditional_complete) then
1110        uncomplete vi
1111        uncomplete vim
1112        complete {vi,vim,gvim,nvi,elvis} 	n/*/f:^*.{o,a,so,sa,aux,dvi,log,fig,bbl,blg,bst,idx,ilg,ind,toc}/
1113        complete {ispell,spell,spellword}	'n@-d@`ls /usr/lib/ispell/*.aff | sed -e "s/\.aff//" `@' 'n/*/f:^*.{o,a,so,sa,aux,dvi,log,fig,bbl,blg,bst,idx,ilg,ind,toc}/'
1114        complete elm	'n/-[Ai]/f/' 'c@=@F:$HOME/Mail/@' 'n/-s/x:\<subject\>/'
1115        complete ncftp	'n@*@`sed -e '1,2d' $HOME/.ncftp/bookmarks | cut -f 1,2 -d "," | tr "," "\012" | sort | uniq ` '@
1116        complete bibtex	'n@*@`ls *.aux | sed -e "s/\.aux//"`'@
1117        complete dvi2tty	n/*/f:*.dvi/	# Only files that match *.dvi
1118	uncomplete gv
1119	uncomplete ghostview
1120        complete {gv,ghostview}	'n/*/f:*.{ps,eps,epsi}/'
1121        complete enscript \
1122		'c/--/(columns= pages= header= no-header truncate-lines \
1123			line-numbers setpagedevice= escapes font= \
1124			header-font= fancy-header no-job-header \
1125			highlight-bars indent= filter= borders page-prefeed \
1126			no-page-prefeed lineprinter lines-per-page= mail \
1127			media= copies= newline= output= missing-characters \
1128			printer= quiet silent landscape portrait \
1129			baselineskip= statusdict= title= tabsize= underlay= \
1130			verbose version encoding pass-through download-font= \
1131			filter-stdin= help highlight-bar-gray= list-media \
1132			list-options non-printable-format= page-label-format= \
1133			printer-options= ul-angle= ul-font= ul-gray= \
1134			ul-position= ul-style= \
1135		     )/'
1136    endif
1137
1138    complete dpkg \
1139		'c/--{admindir,instdir,root}=/d/' \
1140		'c/--debug=/n/' \
1141		'c/--{admindir,debug,instdir,root}/(=)//' \
1142		'c/--/(admindir= debug= instdir= root= \
1143			assert-support-predepends assert-working-epoch \
1144			audit auto-deconfigure clear-avail \
1145			compare-versions configure contents control \
1146			extract force-bad-path field \
1147			force-configure-any force-conflicts \
1148			force-depends force-depends-version force-help \
1149			force-hold force-non-root \
1150			force-overwrite-diverted \
1151			force-remove-essential force-remove-reinstreq \
1152			forget-old-unavail fsys-tarfile get-selections \
1153			help ignore-depends info install largemem \
1154			license list listfiles merge-avail no-act \
1155			pending predep-package print-architecture \
1156			print-gnu-build-architecture \
1157			print-installation-architecture print-avail \
1158			purge record-avail recursive refuse-downgrade \
1159			remove search set-selections selected-only \
1160			skip-same-version smallmem status unpack \
1161			update-avail version vextract \
1162		      )//' \
1163		'n/{-l}/`dpkg -l|awk \{print\ \$2\}`/' \
1164		'n/*/f:*.deb'/
1165    complete dpkg-deb 	   'c/--{build}=/d/' \
1166			   'c/--/(build contents info field control extract \
1167				 vextract fsys-tarfile help version \
1168				 license)//' \
1169			   'n/*/f:*.deb/'
1170    complete apt-get \
1171	        'c/--/(build config-file diff-only download-only \
1172		   fix-broken fix-missing force-yes help ignore-hold no-download \
1173		   no-upgrade option print-uris purge reinstall quiet simulate \
1174		   show-upgraded target-release tar-only version yes )/' \
1175	    	'c/-/(b c= d f h m o= q qq s t x y )/' \
1176 		'n/{source,build-dep}/x:<pkgname>/' \
1177 		'n/{remove}/`dpkg -l|grep ^ii|awk \{print\ \$2\}`/' \
1178 		'n/{install}/`apt-cache pkgnames | sort`/' \
1179 		'C/*/(update upgrade dselect-upgrade source \
1180		   build-dep check clean autoclean install remove)/'
1181    complete apt-cache \
1182 		'c/--/(all-versions config-file generate full help important \
1183 		names-only option pkg-cache quiet recurse src-cache version )/' \
1184 	    	'c/-/(c= h i o= p= q s= v)/' \
1185  		'n/{search}/x:<regex>/' \
1186 		'n/{pkgnames,policy,show,showpkg,depends,dotty}/`apt-cache pkgnames | sort`/' \
1187 		'C/*/(add gencaches showpkg stats dump dumpavail unmet show \
1188 		search depends pkgnames dotty policy )/'
1189
1190    unset noglob
1191    unset _complete
1192    unset traditional_complete
1193endif
1194
1195end:
1196	onintr
1197