added _command completion function and extended Perforce completion, both written by
Frank Cusack (frank@google.com)
This commit is contained in:
parent
47bb2a571e
commit
c29fd79ff3
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# <![CDATA[
|
# <![CDATA[
|
||||||
#
|
#
|
||||||
# $Id: bash_completion,v 1.22 2001/08/16 17:27:02 ianmacd Exp $
|
# $Id: bash_completion,v 1.23 2001/08/16 17:49:39 ianmacd Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -81,9 +81,6 @@ complete -A helptopic help
|
|||||||
# unalias completes with aliases
|
# unalias completes with aliases
|
||||||
complete -a unalias
|
complete -a unalias
|
||||||
|
|
||||||
# various commands complete with commands
|
|
||||||
complete -c command type nohup exec nice eval strace gdb sudo
|
|
||||||
|
|
||||||
# bind completes with readline bindings (make this more intelligent)
|
# bind completes with readline bindings (make this more intelligent)
|
||||||
complete -A binding bind
|
complete -A binding bind
|
||||||
|
|
||||||
@ -1253,26 +1250,82 @@ _cd()
|
|||||||
}
|
}
|
||||||
complete -F _cd -o filenames cd
|
complete -F _cd -o filenames cd
|
||||||
|
|
||||||
# Basic Perforce completion
|
# A meta-command completion function, for commands like sudo, which often
|
||||||
|
# need to complete on a command, followed by a file-name
|
||||||
|
#
|
||||||
|
_command()
|
||||||
|
{
|
||||||
|
local cur
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
|
||||||
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
|
COMPREPLY=( $( compgen -c $cur ) )
|
||||||
|
else
|
||||||
|
# XXX sudo chkconfig should complete just as chkconfig would
|
||||||
|
COMPREPLY=( $( compgen -f $cur ) )
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
complete -F _command -o filenames type nohup exec nice eval strace sudo gdb
|
||||||
|
|
||||||
|
# Basic Perforce completion by Frank Cusack (frank@google.com)
|
||||||
#
|
#
|
||||||
have p4 &&
|
have p4 &&
|
||||||
_p4()
|
_p4()
|
||||||
{
|
{
|
||||||
local cur
|
local cur prev prev2 p4commands p4filetypes
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
[ $COMP_CWORD -gt 1 ] && return 0
|
# rename isn't really a command
|
||||||
COMPREPLY=( $( compgen -W 'add admin branch branches change changes \
|
p4commands="add admin branch branches change changes client \
|
||||||
client clinets counter counters delete depot depots \
|
clients counter counters delete depot depots describe \
|
||||||
describe diff diff2 dirs edit filelog files fix fixes \
|
diff diff2 dirs edit filelog files fix fixes flush \
|
||||||
flush fstat group groups have help info integrate \
|
fstat group groups have help info integrate integrated \
|
||||||
integrated job jobs jobspec label labels labelsync \
|
job jobs jobspec label labels labelsync lock obliterate \
|
||||||
lock obliterate opened passwd print protect rename \
|
opened passwd print protect rename reopen resolve \
|
||||||
reopen resolve resolved revert review reviews set \
|
resolved revert review reviews set submit sync triggers \
|
||||||
submit sync triggers typemap unlock user users verify \
|
typemap unlock user users verify where"
|
||||||
where' $cur ) )
|
p4filetypes="ctext cxtext ktext kxtext ltext tempobj ubinary \
|
||||||
|
uresource uxbinary xbinary xltext xtempobj xtext \
|
||||||
|
text binary resource"
|
||||||
|
|
||||||
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
|
COMPREPLY=( $( compgen -W "$p4commands" $cur ) )
|
||||||
|
elif [ $COMP_CWORD -eq 2 ]; then
|
||||||
|
case "$prev" in
|
||||||
|
help)
|
||||||
|
COMPREPLY=( $( compgen -W "simple commands \
|
||||||
|
environment filetypes jobview revisions \
|
||||||
|
usage views $p4commands" $cur ) )
|
||||||
|
;;
|
||||||
|
admin)
|
||||||
|
COMPREPLY=( $( compgen -W "checkpoint stop" $cur ) )
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
elif [ $COMP_CWORD -gt 2 ]; then
|
||||||
|
prev2=${COMP_WORDS[COMP_CWORD-2]}
|
||||||
|
case "$prev" in
|
||||||
|
-t)
|
||||||
|
case "$prev2" in
|
||||||
|
add|edit|reopen)
|
||||||
|
COMPREPLY=( $(compgen -W "$p4filetypes" $cur) )
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
[ "$have" ] && complete -F _p4 -o default p4
|
[ "$have" ] && complete -F _p4 -o default p4
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user