Examples of the compete command for the tcsh shell. First the syntax. Complete is a builtin comand for the tcsh shell. Complete allows you to control what the shell matches when it does a file completion depending on the command you are using. (It also works on local and environment variables, and aliases.) For example take xv - the all powerfull graphic viewer. YEA! We want to limit the files matched when we use xv to only image files. So we could do this in the tcsh: ~% complete xv 'p/1/f:*.{gif,jpg,jpeg,tiff,ps,png,pgm,ppm,pbm,xpm,bmp,rgb}/' This would limit the files matched when you hit tab (or what ever) to only files with the above extensions. [ From the man page ] complete [command [word/pattern/list[:select]/[[suffix]/] ...]] (+) Without arguments, lists all completions. With command, lists completions for command. With command and word etc., defines completions. command may be a full command name or a glob-pattern (see Filename substitution). It can begin with `-' to indicate that completion should be used only when command is ambiguous. word specifies which word relative to the current word is to be completed, and may be one of the following: c Current-word completion. pattern is a glob-pattern which must match the beginning of the current word on the command line. pattern is ignored when completing the current word. C Like c, but includes pattern when completing the current word. n Next-word completion. pattern is a glob-pattern which must match the beginning of the previous word on the command line. N Like n, but must match the beginning of the word two before the current word. p Position-dependent completion. pattern is a numeric range, with the same syntax used to index shell variables, which must include the current word. list, the list of possible completions, may be one of the following: a Aliases b Bindings (editor commands) c Commands (builtin or external commands) C External commands which begin with the supplied path prefix d Directories D Directories which begin with the supplied path prefix e Environment variables f Filenames F Filenames which begin with the supplied path prefix g Groupnames j Jobs l Limits n Nothing s Shell variables S Signals t Plain (``text'') files T Plain (``text'') files which begin with the supplied path prefix v Any variables u Usernames x Like n, but prints select when list-choices is used. X Completions $var Words from the variable var (...) Words from the given list `...` Words from the output of command -------------------------------------------------------------------------------- # I think this one is incomplete. complete acroread 'c/-/(display e help helpall iconic print P setenv \ toPostScript pairs xrm)/' 'n/-setenv/e/=/' \ 'p/*/f:*.pdf/' complete alias 'p/1/a/' # I think apanel is sgi specific so of no use to you complete apanel 'c/-/(dbscale spinaltap listeningled)/' complete bg 'c/%/j/' # cc again is sgi's cc. complete cc 'c/-/(g0 mips1 cckr ansi ansiposix xansi O2 fullwarn wlint float \ prototypes noprototypes non_shared shared call_shared elf coff)/' \ 'n/*/f:*.[cao]/' complete cd 'p/1/d/' # cdd is this alias (basically cd from home): alias cdd 'cd ~/\!$' complete cdd 'p@1@D:'$HOME'/@' complete chown 'p/2-/f/' 'c/*./g/' 'p/1/u/./' complete -./con* 'p@0@(./configure)@' # This one needs more work complete ./configure 'c/--/(help)/' # This is probably sgi's as opposed to the GNU find complete find 'n/-name/f/' 'n/-newer/f/' 'n/-{,n}cpio/f/' \ 'n/-exec/c/' 'n/-ok/c/' 'n/-user/u/' \ 'n/-group/g/' 'n/-fstype/(nfs 4.2)/' \ 'n/-type/(b c d f l p s)/' \ 'c/-/(name newer cpio ncpio exec ok user group fstype type atime \ ctime depth inum ls mtime nogroup nouser perm print prune \ size xdev)/' 'p/*/d/' complete fg 'c/%/j/' complete ghostview 'c/-/(10x14 a3 a4 a5 arguments b4 b5 center color date dpi \ executive folio force forcemedia forceorientation grayscale \ labels landscape ledger legal letter locator magstep monochrome \ ncdwm nocenter nodate nolabels nolocator noncdwm noopenwindows \ noquiet noswap notitle nosafer openwindows page quarto quiet \ portrait resolution safer seascape statement swap tabloid title \ upsidedown xdpi ydpi)/' 'n/-{{,x,y}dpi,resolution}/x:dpi/' \ 'n/-{page,magstep}/n/' 'p/*/f:*.ps/' complete gnuplot 'c/-/(clear gray mono pointsize tvtwm)/' complete gunzip 'n/*/f:*.{gz,tgz}/' complete gzcat 'n/*/f:*.{gz,tgz,z,Z}/' complete install-info 'c/--dir-file=/f:dir/' 'c/--info-file=/f:*.info/' \ 'c/--info-dir=/d/' 'C/--{di,e,i,s}/(--dir-file --entry \ --info-file --info-dir --item --section)/=' \ 'c/--/(delete dir-file entry help info-file info-dir \ item quiet remove section version)/' complete kill 'c/-/S/ c/%/j/' complete killall 'c/-/S/' complete limit 'n/*/l/' complete lha 'c/*w=/d/' 'p/1/(a c d e l m p t u v x)/' \ 'p/*/f:*.{lha,lzh}/' # The main reason I wrote this one for Lynx was to have the current directory # automatically completed for file:/ urls so that I can quickly view an HTML # file in the current directory. You will probably want to change the default # web server to complete from an http link. complete lynx 'C/-{au,cac,cf,di,ed,er,ho,i,ne,rest,ter}/(-auth -cache \ -cfg -display -editor -error_file -homepage -index \ -newschunksize -newsmaxchunk -restrictions -term)/=/' \ 'c/-/(anonymous auth base book buried_news cache case \ cfg child cookies crawl display dump editor emacskeys \ enable_scrollback error_file fileversions force_html \ from ftp get_data head help historical homepage \ image_links index link localhost locexec mime_header \ minimal newschunksize newsmaxchunk nobrowse noexec \ nofilereferer nofilereferer nolist nolog nopause \ noprint noredir noreferer nosocks nostatus number_links \ popup post_data print pseudo_inlines raw realm reload \ restrictions resubmit_posts rlogin selective show_cursor \ source startfile_ok telnet term trace traversal \ underscore validate version vikeys)/' \ 'c@file:/@F:/@' 'c@file:@$cwd@/@' \ 'c@http://atlas.cs.york.ac.uk/~'$USER'/@F:'$HOME'/web@' \ 'c@http://atlas.cs.york.ac.uk/~@u@/' \ 'c@http://atlas.cs.york.ac.uk/@F:/usr/group/web@/@' \ 'c@http://www@(.york.ac.uk)@/@' \ 'c@http://a@(tlas.cs.york.ac.uk)@/@' \ 'c@http://w@(ww)@.@' \ 'c@http://@(atlas www)@.@' \ 'p@*@(http:// file: ftp:// gopher:// news://)@@' complete man 'n/-d/f/' 'p/1/c/' # Script of mine to format man pages complete mantocat 'p/*/f:*.{1,2,3,4,5,6,7,8,l,man}/' complete maplay 'n/*/f:*.mp2/' # Mail program so probably of no use to you complete mush "c/-{H,headers}:/(a d f m n o p r s u)//" \ "c/-h/(eaders)/:/" "c/-H/(:)//" \ "c/-/(blindcarbon carbon debug draft echo folder \ headers init interact mailbox noinit noheaders \ readonly shell source subject send verbose)/" \ "c@+@F:$HOME/Mail/@" \ "n/-{f,folder,F,source,h,draft,I,init,m,mailbox}/f/" \ "n/-{blindcarbon,carbon,debug,echo,H ,interact, \ noinit,noheaders,readonly,shell,subject,send,verbose}/n/" \ "n/mush/(-)//" # If you don't know what ncftp is then get it (ftp.ncftp.com) It is like ftp but # does the anonymous stuff for you and keeps a bookmarks file. This completion # completes from the bookmark file complete ncftp 'c/-/(a d C D f g G H L n p r R u V)/' \ 'n/-p/x:Port number to dial/' \ 'n/-d/x:Redial period (in seconds)/' \ 'n/-g/x:No. of redials to give up after/' \ 'n/-n/x:Max age of files to get (in days)/' \ 'C@*.*@`cut -d, -f2<~/.ncftp/bookmarks|sed 1,2d`@' \ 'p@*@`cut -d, -f1<~/.ncftp/bookmarks|sed 1,2d`@' complete netscape 'c/-/(install no-install mono)/' complete nohup 'p/1/c/' 'n/*/f/' complete nroff 'c/-/(man)/' 'n/-man/f:*.{man,[123456ln]}/' complete pushd 'n/*/d/' complete ping 'p/1/$hostnames/' complete printenv 'p/1/e/' complete psnup 'c/-[pP]/(a3 a4 a5 b5 letter legal 10x14)/' \ 'c/-/(2 4 6 8 c b d f h H l m p P q r s w W)/' \ 'p/*/f:*.ps/' complete psresize 'c/-[pP]/(a3 a4 a5 b5 letter legal 10x14)/' \ 'c/-/(h H p P q w W)/' 'p/*/f:*.ps/' complete psselect 'c/-/(e o p q r)/' 'p/*/f:*.ps/' complete pushd 'n/*/d/' # I can probably do better than this complete rcp 'c/*:/f/' 'p/1/$hostnames/:' complete rd 'n/*/d/' complete rlogin 'n/*/$hostnames/' complete rmdir 'n/*/d/' complete rsh 'n/*/$hostnames/' # virtual console program which I don't use often complete screen 'c/-/(a A c d D e f h i list L m O q r R s S t T v wipe x)/'\ 'n/-r/$hostnames/' 'n/-c/f/' 'n/-s/c/' complete set 'p/1/s/' complete setenv 'p/1/e/' complete stop 'c/%/j/' complete talk 'c/*@/$hostnames/' 'p/1/u/@' 'p/*/n/' complete tin 'c/-/(a c C d f g h H I m M n P q Q r R s S u U v w z Z)/'\ 'n/-f/f/' 'n/-{I,m,s}/d/' 'n/-M/u/' \ 'n@-g@`gawk /\^\[\^\#\ \\{\\}t\]/\{for\(i=3\;i\<=NF\;i++\)print\ \$i\}<~/.tin/newsrctable`@' # SGI program complete toolchest 'c/-/(decal hidetitle horizontal icon nodecal showtitle title)/' complete unalias 'n/*/a/' complete uncompress 'n/*/f:*.Z/' complete unlimit 'n/*/l/' complete unpack 'n/*/f:*.z/' complete unset 'p/1/s/' complete unsetenv 'p/1/e/' complete unzip 'C/-Z/(-Z)/' 'c/-?/(c f l p t u v z a b j n o q s C L M V \ X $)//' 'c/-/(c f l p t u v z Z)//' 'c/-d/d/' 'p/*/f:*.zip/' # HTML checker complete weblint 'c/-/(d e f i l pedantic s stderr t todo help \ U urlget v version warnings x)/' \ 'n/-x/(Netscape Microsoft)/' 'p/*/f:*.{htm,html}/' complete which 'n/*/c/' complete where 'n/*/c/' complete whereis 'n/*/c/' # Program to add WIDTH and HEIGHT to IMG in HTML complete wwwis 'c/-/(debug imagesize usage version)/' \ 'p/*/f:*.{htm,html}/' complete xdvi 'p/*/f:*.dvi/' complete xhost 'p/1/$hostnames/' # check the file formats as I may have compiled a few extra into my xv. complete xv 'p/1/f:*.{gif,jpg,jpeg,tiff,ps,png,pgm,ppm,pbm,xpm,bmp,rgb}/' \ 'c/-/(help display geometry fixed expand aspect perfect owncmap \ ninstall quick24 slow24 best24 root rmode quit clear)/' # Dodgy x program from ftp.x.org complete xwit 'c/-/(backingstore bitmap colormap columns display iconify \ iconmove iconname id keyrepeat mask move name names \ nobackingstore nokeyrepeat nosave nosaveunder pop resize \ riconmove rmove root rows rwarp save saveunder select \ sync unmap warp)/' \ 'n/-display/$hostnames/:/' \ 'n/-{bitmap,mask}/f/' \ 'p/*/n/' # SGI's xterm/rxvt equivalent complete xwsh 'n@-{fn,{bold,bolditalic,italic}font}@`/usr/local/s/GetFonts`@' \ 'n/-anchor/(northwest north northeast east southeast south \ southwest west center static)/' 'n/-e/c/' 'n/-log/f/' \ 'c/-/(anchor autofork bg bold boldfont bolditalicfont cc \ console cursor cursorbg cursorfg display e fg fn geometry help \ hold holdonerror ibm iconic icontitle italicfont keymap listen \ log max min name nokeyboard nomenu noscrollbar nosend nopgrp \ redirect selbg selfg sl title transient ut vb vt100 xrm)/' \ 'n/-{autofork,console,help,hold{,onerror},ibm,iconic,no{keyboard, \ menu,pgrp,scrollbar,send},ut,vb}/n/' # Alternative to talk complete ytalk 'c/-/(i s Y)/' 'c/*@/$hostnames/' 'p/*/u/@'