home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / bash / completion-contrib / p4 < prev    next >
Encoding:
Text File  |  2006-08-28  |  1.1 KB  |  55 lines

  1. # Perforce completion by Frank Cusack <frank@google.com>
  2. #
  3. # $Id: p4,v 1.3 2003/12/31 08:22:37 ianmacd Exp $
  4.  
  5. _p4()
  6. {
  7.     local cur prev prev2 p4commands p4filetypes
  8.  
  9.     COMPREPLY=()
  10.     cur=${COMP_WORDS[COMP_CWORD]}
  11.     prev=${COMP_WORDS[COMP_CWORD-1]}
  12.  
  13.     # rename isn't really a command
  14.     p4commands="$( p4 help commands | awk 'NF>3 {print $1}' )"
  15.     p4filetypes="ctext cxtext ktext kxtext ltext tempobj ubinary \
  16.         uresource uxbinary xbinary xltext xtempobj xtext \
  17.         text binary resource"
  18.  
  19.     if [ $COMP_CWORD -eq 1 ]; then
  20.         COMPREPLY=( $( compgen -W "$p4commands" -- $cur ) )
  21.     elif [ $COMP_CWORD -eq 2 ]; then
  22.         case "$prev" in
  23.         help)
  24.             COMPREPLY=( $( compgen -W "simple commands \
  25.                 environment filetypes jobview revisions \
  26.                 usage views $p4commands" -- $cur ) )
  27.             ;;
  28.         admin)
  29.             COMPREPLY=( $( compgen -W "checkpoint stop" -- $cur ) )
  30.             ;;
  31.         *)
  32.             ;;
  33.         esac
  34.     elif [ $COMP_CWORD -gt 2 ]; then
  35.         prev2=${COMP_WORDS[COMP_CWORD-2]}
  36.         case "$prev" in
  37.         -t)
  38.             case "$prev2" in
  39.             add|edit|reopen)
  40.                 COMPREPLY=( $( compgen -W "$p4filetypes" \
  41.                            -- $cur) )
  42.                 ;;
  43.             *)
  44.                 ;;
  45.             esac
  46.             ;;
  47.         *)
  48.             ;;
  49.         esac
  50.     fi
  51.  
  52.     return 0
  53. }
  54. complete -F _p4 -o default p4 g4
  55.