60 lines
1.5 KiB
Plaintext
Raw Normal View History

# Perforce completion by Frank Cusack <frank@google.com>
have p4 || return
_p4()
{
local cur prev words cword
_init_completion || return
local p4commands p4filetypes
2009-10-04 19:42:50 +02:00
# rename isn't really a command
p4commands="$( p4 help commands | awk 'NF>3 {print $1}' )"
p4filetypes="ctext cxtext ktext kxtext ltext tempobj ubinary \
uresource uxbinary xbinary xltext xtempobj xtext \
text binary resource"
if [ $cword -eq 1 ]; then
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W "$p4commands" -- "$cur" ) )
elif [ $cword -eq 2 ]; then
case $prev in
2009-10-04 19:42:50 +02:00
help)
COMPREPLY=( $( compgen -W "simple commands \
environment filetypes jobview revisions \
usage views $p4commands" -- "$cur" ) )
;;
admin)
COMPREPLY=( $( compgen -W "checkpoint stop" -- "$cur" ) )
;;
*)
;;
esac
elif [ $cword -gt 2 ]; then
case $prev in
2009-10-04 19:42:50 +02:00
-t)
case ${words[$cword-2]} in
2009-10-04 19:42:50 +02:00
add|edit|reopen)
COMPREPLY=( $( compgen -W "$p4filetypes" -- "$cur") )
;;
*)
;;
esac
;;
*)
;;
esac
fi
2009-10-04 19:42:50 +02:00
return 0
2009-06-08 21:22:43 +03:00
} &&
complete -F _p4 -o default p4 g4
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh