# AFS commands completion by Karsten Petersen _afs-fs() { local cur prev first full aliases commands COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} first=${COMP_WORDS[1]} full="apropos checkservers checkvolumes cleanacl copyacl \ diskfree examine exportafs flush flushmount flushvolume \ getcacheparms getcellstatus getclientaddrs getcrypt \ getserverprefs help listacl listaliases listcells \ listquota lsmount messages mkmount newalias newcell \ quota rmmount rxstatpeer rxstatproc setacl setcachesize \ setcell setclientaddrs setcrypt setquota setserverprefs \ setvol storebehind sysname whereis whichcell wscell" aliases="ca la lq sa sq" commands="$full $aliases" if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) return 0 fi # $COMP_CWORD -gt 1 case "$first" in apropos) case "$prev" in -topic) return 0 ;; *) COMPREPLY=( $( compgen -W "-topic -help" -- "$cur" ) ) ;; esac ;; # checkservers # checkvolumes # cleanacl copyacl|ca) case "$prev" in -fromdir|-todir) _filedir ;; *) COMPREPLY=( $( compgen -W "-fromdir -todir -clear -id -if -help" -- "$cur" ) ) _filedir ;; esac ;; # diskfree # examine # exportafs # flush # flushmount # flushvolume # getcacheparms # getcellstatus # getclientaddrs # getcrypt # getserverprefs help) case "$prev" in -topic) COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) ;; -*) COMPREPLY=( $( compgen -W "-topic -admin -help $commands" -- "$cur" ) ) ;; *) if [ $COMP_CWORD -eq 2 ]; then COMPREPLY=( $( compgen -W "-topic -admin -help $commands" -- "$cur" ) ) else COMPREPLY=( $( compgen -W "-admin -help" -- "$cur" ) ) fi ;; esac ;; listacl|la) case "$prev" in -path) _filedir ;; *) COMPREPLY=( $( compgen -W "-path -id -if -help" -- "$cur" ) ) _filedir ;; esac ;; # listaliases # listcells listquota|lq) case "$prev" in -path) _filedir ;; *) COMPREPLY=( $( compgen -W "-path -help" -- "$cur" ) ) _filedir ;; esac ;; lsmount) case "$prev" in -dir) _filedir ;; *) COMPREPLY=( $( compgen -W "-dir -help" -- "$cur" ) ) _filedir ;; esac ;; # messages mkmount) case "$prev" in -dir) _filedir -d return 0 ;; -vol|-cell) return 0 ;; *) COMPREPLY=( $( compgen -W "-dir -vol -cell -rw -fast -help" -- "$cur" ) ) _filedir -d ;; esac ;; # newalias # newcell # quota rmmount) case "$prev" in -dir) _filedir -d return 0 ;; *) COMPREPLY=( $( compgen -W "-dir -help" -- "$cur" ) ) _filedir -d ;; esac ;; # rxstatpeer # rxstatproc setacl|sa) case "$prev" in -dir) _filedir -d return 0 ;; -acl) return 0 ;; *) COMPREPLY=( $( compgen -W "-dir -acl -clear -negative -id -if -help" -- "$cur" ) ) _filedir -d ;; esac ;; # setcachesize # setcell # setclientaddrs # setcrypt setquota|sq) case "$prev" in -path) _filedir return 0 ;; -max) return 0 ;; *) COMPREPLY=( $( compgen -W "-path -max -help" -- "$cur" ) ) _filedir ;; esac ;; # setserverprefs # setvol # storebehind # sysname # whereis # whichcell # wscell *) ;; esac return 0 } _afs-pts() { local cur prev first full aliases commands COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} first=${COMP_WORDS[1]} full="adduser apropos chown creategroup createuser delete \ examine help listentries listmax listowned membership \ removeuser rename setfields setmax" aliases="groups me" commands="$full $aliases" if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) return 0 fi # $COMP_CWORD -gt 1 case "$first" in adduser) case "$prev" in -user|-group|-cell) return 0 ;; *) COMPREPLY=( $( compgen -W "-user -group -cell -noauth -force -help" -- "$cur" ) ) ;; esac ;; apropos) case "$prev" in -topic) return 0 ;; *) COMPREPLY=( $( compgen -W "-topic -help" -- "$cur" ) ) ;; esac ;; # chown # creategroup # createuser # delete # examine help) case "$prev" in -topic) COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) ;; -*) COMPREPLY=( $( compgen -W "-topic -admin -help $commands" -- "$cur" ) ) ;; *) if [ $COMP_CWORD -eq 2 ]; then COMPREPLY=( $( compgen -W "-topic -admin -help $commands" -- "$cur" ) ) else COMPREPLY=( $( compgen -W "-admin -help" -- "$cur" ) ) fi ;; esac ;; # listentries # listmax listowned) case "$prev" in -nameorid|-cell) return 0 ;; *) COMPREPLY=( $( compgen -W "-nameorid -cell -noauth -force -help" -- "$cur" ) ) ;; esac ;; membership|groups|me) case "$prev" in -nameorid|-cell) return 0 ;; *) COMPREPLY=( $( compgen -W "-nameorid -cell -noauth -force -help" -- "$cur" ) ) ;; esac ;; removeuser) case "$prev" in -user|-group|-cell) return 0 ;; *) COMPREPLY=( $( compgen -W "-user -group -cell -noauth -force -help" -- "$cur" ) ) ;; esac ;; # rename # setfields # setmax *) ;; esac return 0 } _afs-klog() { local cur prev options options="-x -principal -password -cell -servers -pipe -silent -lifetime -setpag -tmp -help" COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) else case "$prev" in -principal|-password|-cell|-servers|-lifetime) return 0 ;; *) COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) ;; esac fi return 0 } _afs-unlog() { local cur prev options options="-cell -help" COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) else case "$prev" in -cell) return 0 ;; *) COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) ;; esac fi return 0 } _afs-tokens() { local cur cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $( compgen -W "-help" -- "$cur" ) ) return 0 } complete -F _afs-fs fs complete -F _afs-pts pts complete -F _afs-klog klog klog.krb complete -F _afs-unlog unlog complete -F _afs-tokens tokens tokens.krb