# complete
# configure command line completion for tcsh shell

# Environment settings used for completion
# $hostnames - a list of the hosts you are most likely to finger
# $usernames - a list of user names you are most likely to connect to remote hosts as

if (! $?hostnames) then
   set hostnames=(localhost)
endif
if (! $?usernames) then
   set usernames=(`whoami` root)
endif
if (! $?complete_html) then
   set complete_html='htm,html,shtml,xml,txt,gif,jpg,jpeg,png'
endif
if (! $?complete_perl) then
   set complete_perl='pl,pm,cgi,lib,t,th'
endif

# get all uid's: awk -F : \{print\ \$3\} /etc/passwd
# get all gid's: awk -F : \{print\ \$4\} /etc/passwd
# get all font names: xlsfonts | awk -F - \{print\ \$3\}
# get all filesystem types: grep -v nodev /proc/filesystems
# get all init services: chkconfig --list | perl -ne print\ \"\$1\\n\"\ if\ /^\(\\w\+\)/
# get all manpage sections: perl -ne 'print join(" ",split(":",$1)) if /^MANSECT\s+(.*)/' /etc/man.config
#                           perl -ne print\ join\(\"\ \",split\(/:/,\$1\)\)\ if\ /^MANSECT\\s+\(.\*\)/  /etc/man.config

# show uid:username: cat /etc/passwd | awk -F : BEGIN\ \{OFS=\":\"\}\ \{print\ \$3,\$1\}

# Configure the command completion for come common commands

# complete some commands with directory names only
complete cd 'p/1/d/'
complete chdir 'p/1/d/'
complete pushd 'p/1/d/'
#complete ov 'p/1/d/'  # unless we can complete on the directory above :)
complete rd 'p/1/d/'

complete rmpath 'p/1/d/'
complete addpath 'p/1/d/'
complete pushpath 'p/1/d/'

# wc (GNU textutils) 1.22
complete wc \
 'c/--/(bytes chars help lines version words)/' \
 'c/-/(c l w)/'

# rmdir (GNU fileutils) 4.0
complete rmdir \
 'c/--/(help ignore-fail-on-non-empty parents verbose version)/' \
 'c/-/(p)/' \
 'p/*/d/'

# complete some commands using shell variables
complete set 'p/1/s/'
complete unset 'p/1/s/'

# complete some commands with valid commands
# man, version 1.5f
complete man \
 'n/-C/f/' 'n/-M/d/' 'n/-P/c/' \
 'n/-m/x:system name/' \
 'n/-p/(e g p r t v)/' \
 'n@-S@`perl -ne print\ join\(\"\ \",split\(/:/,\$1\)\)\ if\ /^MANSECT\\s+\(.\*\)/  /etc/man.config`@' \
 'c/--/(help path preformat version)/' \
 'c/-/(C D F K M P S W a c d f h k m p t w)/' \
 'p/*/c/'

# complete some commands with the names of all aliases
complete alias 'p/1/a/'
complete unalias 'p/1/a/'

# complete some commands with hostnames
complete finger \
 'c/-/(l m p s)/' \
 'c/*@/$hostnames/' \
 'p/*/u/@'

complete ftp \
 'c/-/(d g i v)/' \
 'p/1/$hostnames/' \
 'n/-*/$hostnames/' \
 'p/2-/x:port number/'

complete sftp \
 'n/-c/(des 3des blowfish idea arcfour twofish any anystd anycipher)/' \
 'n/-s/d/' \
 'n/-p/x:port number/' \
 'n/-d/x:debug level 0-99 or module/' \
 'c/-/(c d p s v)/' \
 'c/*@/$hostnames/' \
 'p/*/$usernames/@'

# ssh: SSH Version 2.0.13
complete ssh \
 'n/-l/$usernames/' \
 'n/-c/(des 3des blowfish idea arcfour twofish any anystd anycipher)/' \
 'n/-{i,F}/f/' \
 'n/-e/x:escape character/' \
 'n/-p/x:port number/' \
 'n/-d/x:debug level 0-99 or module/' \
 'c/-/(C F L P R S V a c d e f h i l n o p q t v x)/' \
 'c/+/(C a x)/' \
 'c/*@/$hostnames/' \
 'p/*/$usernames/@'

# more complicated completion
complete kill 'p/*/`pspid`/'
complete killall 'p/*/`pscmd`/'

# prevent precious source code from being completed in a rm command
complete rm 'p/*/f:^*.{pl,pm}/'

# associate commands with their most common file extensions
complete netscape "p/*/f:*.{$complete_html}/"
complete lynx "p/*/f:*.{$complete_html}/"

# GNU find version 4.1
complete find \
 'n/-{anewer,cnewer,fls,fprint,fprint0,fprintf,ilname,iname,ipath,iregex,lname,name,newer,path,regex}/f/' \
 'n/-printf/x:printf style format/' \
 'N/-fprintf/x:printf style format/' \
 'n/-{exec,ok}/c/' 'N/-{exec,ok}/({} \;)/' \
 'n/-user/u/' 'n/-group/g/' \
 'n@-uid@`awk -F : \{print\ \$3\} /etc/passwd`@' \
 'n@-gid@`awk -F : \{print\ \$4\} /etc/passwd`@' \
 'n@-fstype@`grep -v nodev /proc/filesystems`@' \
 'n/-{,x}type/(b c d f l p s)/' \
 'n@-size@x:+/-n b c k w@' \
 'n@-inum@x:+/-inode#@' \
 'n@-links@x:+/-links@' \
 'n@-perm@x:+/-permissions@' \
 'n@-{a,c,m}min@x:+/-minutes@' \
 'n@-{a,c,m}time@x:+/-hours@' \
 'n@-used@x:+/-days@' \
 'n/-mindepth/(1 2 3 4 5 6 7 8 9)/' \
 'n/-maxdepth/(0 1 2 3 4 5 6 7 8 9)/' \
 'c/--/(help version)/' \
 'c/-/(a amin and anewer atime cmin cnewer ctime daystart depth empty \
       exec false fls follow fprint0 fprintf fprintf fstype gid group \
       help ilname iname inum ipath iregex links lname ls maxdepth \
       mindepth mmin mount mtime name newer nogroup noleaf not nouser \
       o ok or path perm print print0 printf prune regex size true type \
       uid used user version xdev xtype)/' \
 'p/*/d/'

# GNU tar version 1.12
complete tar \
 'n/--use-compress-prog/c/' \
 'n/-{C,-directory}/d/' \
 'n/-{N,-after-date,-newer}/(2000-mm-dd hh:mm:ss)/' \
 'n/-{V,-label}/x:volume name/' \
 'n/-{b,-block-size}/x:block size (* 512 bytes)/' \
 'n/-{L,-tape-length}/x:tape length (* 1024 bytes)/' \
 'n/-{F,K,N,T,V,X,f,g,-exclude,-exclude-from,-file, \
      -files-from,-info-script,-listed-incremental, \
      -new-volume-script,-starting-file}/f/' \
 'c/--/(absolute-paths after-date append atime-preserve block-compress \
        block-size catenate checkpoint compare compress concatenate \
        confirmation create delete dereference diff directory exclude \
        exclude-from extract file files-from force-local get gzip \
        ignore-failed-read ignore-zeros incremental info-script interactive \
        keep-old-files label list listed-incremental modification-time \
        multi-volume new-volume-script newer null old-archive one-file-system \
        portability preserve preserve-order preserve-permissions \
        read-full-blocks record-number remove-files same-order same-owner \
        same-permissions sparse starting-file tape-length to-stdout totals \
        uncompress ungzip update use-compress-program verbose verify version)/' \
 'c/-[0-7]/(l m h)/' \
 'c/-/(0 1 2 3 4 5 6 7 A B C F G K L M N O P R S T V \
       W X Z b c d f g h i k l m o p r s t u v w x z)/' \
 'p/*/f/'

# ls (GNU fileutils) 4.0
complete ls \
 'c/--block-size=/x:block size (bytes)/' \
 'c/--color=/(never always auto)/' \
 'c/--format=/(across commas horizontal long single-column verbose vertical)/' \
 'c/--indicator-style=/(none classify file-type)/' \
 'n/-I/f/' 'c/--ignore=/f/' \
 'c/--quoting-style=/(literal shell shell-always c escape)/' \
 'c/--sort=/(extension none size time version)/' \
 'c/--time=/(atime access use ctime status)/' \
 'n/-{T,w}/x: columns/' \
 'c/--{tabsize,width}=/x:columns/' \
 'c/--b/(locksize)/=' \
 'c/--co/(lor)/=' \
 'c/--fo/(rmat)/=' \
 'c/--in/(dicator-style)/=' \
 'c/--quoti/(ng-style)/=' \
 'c/--so/(rt)/=' \
 'c/--ta/(bsize)/=' \
 'c/--ti/(me)/=' \
 'c/--wi/(dth)/=' \
 'c/--/(all almost-all block-size= classify color= dereference directory \
        dired escape file-type format= full-time help hide-control-chars \
        human-readable ignore= ignore-backups indicator-style= inode kilobytes \
        literal no-group numeric-uid-gid quote-name quoting-style= recursive \
        reverse show-control-chars si size sort= tabsize= time= version width=)/' \
 'c/-/(1 A B C D F G H I L N Q R S T U X a b c d f g \
       h i k l m n o p q r s t u v w x)/' \
 'p/*/f/'

# GNU grep 2.3
complete {,e,f}grep \
 'n/-{A,B,C}/x:number of lines of context/' \
 'c/--{after-context,before-context,context}=/x:number of lines of context/' \
 'n/-e/x: regular expression ^?*+{n,m}|\1[a-z][:alpha:]$/' \
 'c/--regexp=/x:regular expression ^?*+{n,m}|\1[a-z][:alpha:]$/' \
 'n/-d/(read skip recurse)/' \
 'c/--directories=/(read skip recurse)/' \
 'n/-f/f/' \
 'c/--file=/f/' \
 'c/--a/(fter-context)/=' \
 'c/--be/(fore-context)/=' \
 'c/--c/(ontext)/=' \
 'c/--d/(irectories)/=' \
 'c/--r/(egexp)/=' \
 'c/--/(after-context= basic-regexp before-context= binary \
        byte-offset context= count directories= extended-regexp \
        file= files-without-match fixed-strings help ignore-case \
        line-number line-regexp no-filename no-messages quiet \
        recursive regexp= revert-matches silent text unix-byte-offsets \
        version word-regexp)/' \
 'c/-/(1 2 3 4 5 6 7 8 9 A B C E F G L U V a b c d e \
       f h i l n q r s u v w x y)/' \
 'p/*/f/'

# less  version 332
complete less \
 'n/-{b,h,j,x,y,z}/x:number/' \
 'n/-{k,o,O,T}/f/' \
 'n/-p/x:pattern to find/' \
 'n/-"/x:alternate quote character to use/' \
 'n/-P{s,m,M,h,=}/x:prompt string to use/' \
 'n/-t/x:ag to locate from tagfile/' \
 'c/--/(help version)/' \
 'c/-/(" 0 1 2 3 4 5 6 7 8 9 ? B C E G I M N O P= PM \
       Ph Pm Ps Q S T U V X a b c d e f g h i j k m n \
       o p q r s t u w x y z) /' \
 'p/*/f/'

# perl 5.005_03
complete perl \
 'n/-{I,x}/d/' \
 'n/-0/x:input record separator in octal/' \
 'n/-l/x:line end processing character in octal/' \
 'n/-d:/x:debugger module/' \
 'n/-V:/x:name of perl configuration variable/' \
 'n/-{m,M}/x:modules to use before script begins/' \
 'n/-e/x:a line of perl code/' \
 'n/-F/x:a pattern to split fields on/' \
 'n/-i/x:extension for backup file for inplace editing/' \
 'n/-D/(0 1 2 3 4 5 6 7 8 9 D H L P S X c f l m o p r s t u x)/' \
 'c/-/(0 D F I M P S T U V V: a c d d: e h i l m n p s u v w x)/' \
 'p/*/f:*.{$complete_perl}/'

# mount-2.9o
complete mount \
 'n/-L/x:volume label/' \
 'n/-U/x:uuid/' \
 'n/-o/(async atime auto defaults dev exec noatime noauto nodev \
        noexec nosuid nouser remount ro rw suid sybc user)/' \
 'n@-t@`cat /proc/filesystems | grep -v nodev`@' \
 'c/-/(F L U V a f h n o r s t v w)/' \
 'p/*/d/'

# umount-2.9o
complete umount \
 'n@-t@`cat /proc/filesystems | grep -v nodev`@' \
 'c/-/(V a h n r t v)/' \
 'p/*/d/'

# Zip 2.1 (April 27th 1996)
complete zip \
 'n/-t/x:mmddyy/' \
 'n/-n/x:file extensions for no compression/' \
 'n/-{i,x}/f/' \
 'n/-b/d/' \
 'c/-/(# $ @ A D F J L T V X b c d e f g h i j k l ll m n o \
       q r s t u v w x y z)/' \
 'p/*/f/'

complete unzip \
 'n/-P/x:password/' \
 'n/-{i,x}/f/' \
 'n/-x/f/' \
 'n/-d/d/' \
 'c/-/($ A B C L M N P S T U V X Z a b c d f j l n o p q qqa \
       t u v x z)/' \
 'p/*/f/'

# cp (GNU fileutils) 4.0
complete cp \
 'n/-S/x:file extension for backups/' \
 'c/--suffix=/x:file extension for backups/' \
 'c/--sparse=/(auto always never)/' \
 'n/-V/(numbered t existing nil never simple)/' \
 'c/--version-control=/(numbered t existing nil never simple)/' \
 'c/--sp/(arse)/=' \
 'c/--su/(ffix)/=' \
 'c/--v/(ersion-control)/=' \
 'c/--/(archive backup force help interactive link no-dereference \
        one-file-system parents preserve recursive sparse= suffix= \
        symbolic-link update verbose version version-control=)/' \
 'c/-/(P R S V a b d f i l p r s u v x)/' \
 'p/*/f/'

# mv (GNU fileutils) 4.0
complete mv \
 'n/-S/x:file extension for backups/' \
 'c/--suffix=/x:file extension for backups/' \
 'n/-V/(numbered t existing nil never simple)/' \
 'c/--version-control=/(numbered t existing nil never simple)/' \
 'c/--s/(uffix)/=' \
 'c/--v/(ersion-control)/=' \
 'c/--/(backup force help interactive suffix=\
        update verbose version version-control=)/' \
 'c/-/(S V b f i u v)/' \
 'p/*/f/'

# xargs GNU xargs version 4.1
# TODO INCOMPLETE
complete xargs \
 'c/--e/(of)/=' \
 'c/--max-a/(rgs)/=' \
 'c/--max-c/(hars)/=' \
 'c/--max-l/(ines)/=' \
 'c/--max-p/(rocs)/=' \
 'c/--r/(eplace)/=' \
 'c/--/(eof= exit help interactive max-args= max-chars= max-lines= \
        max-procs= no-run-if-empty null replace= verbose version)/' \
 'c/-/(0 P e i l n p r s t x)/' \
 'p/*/f/'

# at version 3.1.7
# it's not a perfect representation of the at grammar but is helpful
complete at \
 'n/-f/f/' \
 'n/+/(1)/' \
 'N/+/(minute hour day week month year)/' \
 'c/[0-9]*/(am pm : 0 1 2 3 4 5 6 7 8 9)/' \
 'n/[0-9]/(minute hour day week month year 2000)/' \
 'n/{now,today,tomorrow}/(+)/' \
 'n/{sun,mon,tue,wed,thu,fri,sat,jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec}/(1)/' \
 'n/{midnight,noon,teatime}/(+ today tomorrow sun mon tue wed thu fri sat jan feb mar apr may jun jul aug sep oct nov dec)/' \
 'n/-q/x:queue name: a-z A-Z/' \
 'c/-/(V c d f l m q v)/' \
 'p/1/(now midnight noon teatime 0 1 2 )/' \
 'c/*/n/'

# cvs version 1.10.5
# TODO not complete yet
complete cvs \
   'c/--/(help version)/' \
   'p/1/(add admin checkout commit diff export history import \
         log rdiff release remove rtag status tag update)/'


# A bogus completion to test the options of complete command
complete cplt \
 'n/--aliases/a/' 'n/--bindings/b/' 'n/--commands/c/' 'n@--ext-commands@C:/bin@' \
 'n/--directories/d/' 'n@--pre-directories@D:/etc@' 'n/--environment/e/' \
 'n/--filenames/f/' 'n@--pre-filenames@F:/etc@' 'n/--groups/g/' 'n/--jobs/j/' \
 'n/--limits/l/' 'n/--nothing/n/' 'n/--shell-vars/s/' 'n/--signals/S/' \
 'n/--text-files/t/' 'n@--pre-text-files@T:/etc@' 'n/--variables/v/' \
 'n/--usernames/u/' 'n/--help/x:help text/' 'n/--completions/X/' \
 'c/--/(aliases bindings commands ext-commands directories pre-directories\
        environment filenames pre-filenames groups jobs limits nothing \
        shell-vars signals text-files pre-text-files variables usernames \
        help completions)/'

# chkconfig
complete chkconfig \
 'n@--{list,add,del}@`svcname`@' \
 'c/-/(-list -add -del -level)/' \
 'c/--/(list add del level)/' \
 'n/--level/(2345 345 5)/' \
 'N@--level@`svcname`@' \
 'p/2/(on off reset)/' \
 'p/4/(on off reset)/' \
 'p/1/`svcname`/' \
 'c/*/n/'

# another completion for testing stuff
complete ass \
 'c/--sort=/(hello there)/' \
 'c/--s/(ort)/='

exit 0


    Source: geocities.com/gurucoder/Tools/bsac

               ( geocities.com/gurucoder/Tools)                   ( geocities.com/gurucoder)