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 / apt < prev    next >
Encoding:
Text File  |  2010-11-16  |  4.5 KB  |  158 lines

  1. # Debian apt-get(8) completion.
  2.  
  3. have apt-get &&
  4. _apt_get()
  5. {
  6.     local cur prev special i
  7.  
  8.     COMPREPLY=()
  9.     _get_comp_words_by_ref cur prev
  10.  
  11.     for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  12.         if [[ ${COMP_WORDS[i]} == @(install|remove|autoremove|purge|source|build-dep) ]]; then
  13.             special=${COMP_WORDS[i]}
  14.         fi
  15.     done
  16.  
  17.     if [ -n "$special" ]; then
  18.         case $special in
  19.             remove|autoremove|purge)
  20.                 if [ -f /etc/debian_version ]; then
  21.                     # Debian system
  22.                     COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
  23.                 else
  24.                     # assume RPM based
  25.                     _rpm_installed_packages
  26.                 fi
  27.                 return 0
  28.                 ;;
  29.             source)
  30.                 COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
  31.                     2> /dev/null ) $( apt-cache dumpavail | \
  32.                     command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
  33.                 return 0
  34.                 ;;
  35.             *)
  36.                 COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
  37.                     2> /dev/null ) )
  38.                 return 0
  39.                 ;;
  40.         esac
  41.     fi
  42.  
  43.     case $prev in
  44.         -c|--config-file)
  45.              _filedir
  46.              return 0
  47.              ;;
  48.         -t|--target-release|--default-release)
  49.              COMPREPLY=( $( apt-cache policy | \
  50.                  command grep "release.o=Debian,a=$cur" | \
  51.                  sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
  52.              return 0
  53.              ;;
  54.     esac
  55.  
  56.     if [[ "$cur" == -* ]]; then
  57.         COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y -u -t -b -c -o \
  58.             --download-only --fix-broken --help --version --ignore-missing \
  59.             --fix-missing --no-download --quiet --simulate --just-print \
  60.             --dry-run --recon --no-act --yes --assume-yes --show-upgraded \
  61.             --only-source --compile --build --ignore-hold --target-release \
  62.             --no-upgrade --force-yes --print-uris --purge --reinstall \
  63.             --list-cleanup --default-release --trivial-only --no-remove \
  64.             --diff-only --no-install-recommends --tar-only --config-file \
  65.             --option --auto-remove' -- "$cur" ) )
  66.     else
  67.         COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
  68.             dist-upgrade install remove purge source build-dep \
  69.             check clean autoclean autoremove' -- "$cur" ) )
  70.     fi
  71.  
  72.     return 0
  73. } &&
  74. complete -F _apt_get -o filenames apt-get
  75.  
  76. # Debian apt-cache(8) completion.
  77. #
  78. have apt-cache &&
  79. _apt_cache()
  80. {
  81.     local cur prev special i
  82.  
  83.     COMPREPLY=()
  84.     _get_comp_words_by_ref cur prev
  85.  
  86.     if [ "$cur" != show ]; then
  87.         for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  88.         if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then
  89.             special=${COMP_WORDS[i]}
  90.         fi
  91.         done
  92.     fi
  93.  
  94.  
  95.     if [ -n "$special" ]; then
  96.         case $special in
  97.         add)
  98.             _filedir
  99.             return 0
  100.             ;;
  101.  
  102.         showsrc)
  103.             COMPREPLY=( $( apt-cache dumpavail | \
  104.                 command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
  105.             return 0
  106.             ;;
  107.  
  108.         *)
  109.             COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" 2> /dev/null ) )
  110.             return 0
  111.             ;;
  112.  
  113.         esac
  114.     fi
  115.  
  116.  
  117.     case $prev in
  118.          -c|-p|-s|--config-file|--pkg-cache|--src-cache)
  119.              _filedir
  120.              return 0
  121.              ;;
  122.          search)
  123.              if [[ "$cur" != -* ]]; then
  124.                 return 0
  125.              fi
  126.              ;;
  127.     esac
  128.  
  129.     if [[ "$cur" == -* ]]; then
  130.  
  131.         COMPREPLY=( $( compgen -W '-h -v -p -s -q -i -f -a -g -c \
  132.                 -o --help --version --pkg-cache --src-cache \
  133.                 --quiet --important --full --all-versions \
  134.                 --no-all-versions --generate --no-generate \
  135.                 --names-only --all-names --recurse \
  136.                 --config-file --option --installed' -- "$cur" ) )
  137.     else
  138.  
  139.         COMPREPLY=( $( compgen -W 'add gencaches show showpkg showsrc \
  140.                 stats dump dumpavail unmet search search \
  141.                 depends rdepends pkgnames dotty xvcg \
  142.                 policy madison' -- "$cur" ) )
  143.  
  144.     fi
  145.  
  146.  
  147.     return 0
  148. } &&
  149. complete -F _apt_cache -o filenames apt-cache
  150.  
  151. # Local variables:
  152. # mode: shell-script
  153. # sh-basic-offset: 4
  154. # sh-indent-comment: t
  155. # indent-tabs-mode: nil
  156. # End:
  157. # ex: ts=4 sw=4 et filetype=sh
  158.