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 / portupgrade < prev    next >
Encoding:
Text File  |  2010-11-16  |  1.5 KB  |  58 lines

  1. # bash completion for FreeBSD portupgrade package
  2.  
  3. have portupgrade &&
  4. _portupgrade()
  5. {
  6.     local cur pkgdir prev
  7.  
  8.     pkgdir=${PKG_DBDIR:-/var/db/pkg}/
  9.     _get_comp_words_by_ref cur prev
  10.  
  11.     [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0
  12.  
  13.     COMPREPLY=( $( compgen -d "$pkgdir$cur" ) )
  14.     COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
  15.     COMPREPLY=( ${COMPREPLY[@]%-*} )
  16.  
  17.     return 0
  18. } &&
  19. complete -F _portupgrade -o dirnames portupgrade
  20.  
  21. have portinstall &&
  22. _portinstall()
  23. {
  24.     local cur portsdir prev indexfile
  25.     local -a COMPREPLY2
  26.  
  27.     portsdir=${PORTSDIR:-/usr/ports}/
  28.     _get_comp_words_by_ref cur prev
  29.     # First try INDEX-5
  30.     indexfile=$portsdir/INDEX-5
  31.     # Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
  32.     [[ "${OSTYPE%.*}" == freebsd5 && -f $indexfile ]] ||
  33.         indexfile=$portsdir/INDEX
  34.  
  35.     [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0
  36.  
  37.     COMPREPLY=( $( command grep -E "^$cur" < $indexfile | cut -d'|' -f1 ) )
  38.     COMPREPLY2=( $( command grep -E "^[^\|]+\|$portsdir$cur" < $indexfile | \
  39.         cut -d'|' -f2 ) )
  40.     COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
  41.     COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" )
  42.  
  43.     return 0
  44. } &&
  45. complete -F _portinstall -o dirnames portinstall
  46.  
  47. # _pkg_delete is in pkg_install
  48. type _pkg_delete &>/dev/null && have pkg_deinstall && \
  49. complete -F _pkg_delete -o dirnames pkg_deinstall
  50.  
  51. # Local variables:
  52. # mode: shell-script
  53. # sh-basic-offset: 4
  54. # sh-indent-comment: t
  55. # indent-tabs-mode: nil
  56. # End:
  57. # ex: ts=4 sw=4 et filetype=sh
  58.