home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / dict < prev    next >
Encoding:
Text File  |  2010-11-16  |  2.0 KB  |  78 lines

  1. # dict(1) completion
  2.  
  3. { have dict || have rdict; } && {
  4. _dictdata()
  5. {
  6.     dict $host $port $1 2>/dev/null | sed -ne \
  7.         's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p'
  8. }
  9.  
  10. _dict()
  11. {
  12.     local cur prev host port db dictfile
  13.  
  14.     COMPREPLY=()
  15.     _get_comp_words_by_ref cur prev
  16.     dictfile=/usr/share/dict/words
  17.  
  18.     for (( i=1; i < COMP_CWORD; i++ )); do
  19.         case ${COMP_WORDS[i]} in
  20.             -h|--host)
  21.                 host=${COMP_WORDS[i+1]}
  22.                 [ -n "$host" ] && host="-h $host"
  23.                 i=$((++i))
  24.                 ;;
  25.             -p|--port)
  26.                 port=${COMP_WORDS[i+1]}
  27.                 [ -n "$port" ] && port="-p $port"
  28.                 i=$((++i))
  29.                 ;;
  30.             -d|--database)
  31.                 db=${COMP_WORDS[i+1]}
  32.                 [ -n "$db" ] && host="-d $db"
  33.                 i=$((++i))
  34.                 ;;
  35.             *)
  36.                 ;;
  37.         esac
  38.     done
  39.  
  40.     if [[ "$cur" = -* ]]; then
  41.         COMPREPLY=( $( compgen -W '--host --port --database \
  42.                    --match --strategy --config \
  43.                    --nocorrect --dbs --strats \
  44.                    --serverhelp --info --serverinfo \
  45.                    --noauth --user --key --version \
  46.                    --license --help --verbose --raw \
  47.                    --pager --debug --html --pipesize --client' \
  48.                    -- "$cur" ) )
  49.         return 0
  50.     fi
  51.  
  52.     case $prev in
  53.         -d|--database|-i|-info)
  54.             COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) )
  55.             return 0
  56.             ;;
  57.         -s|--strategy)
  58.             COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) )
  59.             return 0
  60.             ;;
  61.         *)
  62.             ;;
  63.     esac
  64.  
  65.     [ -r $dictfile ] && \
  66.         COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
  67. }
  68. complete -F _dict -o default dict rdict
  69. }
  70.  
  71. # Local variables:
  72. # mode: shell-script
  73. # sh-basic-offset: 4
  74. # sh-indent-comment: t
  75. # indent-tabs-mode: nil
  76. # End:
  77. # ex: ts=4 sw=4 et filetype=sh
  78.