complete only one command
This commit is contained in:
parent
ed35a268d8
commit
9c5105a005
1 changed files with 14 additions and 3 deletions
|
|
@ -1,16 +1,27 @@
|
|||
function _gis_completion {
|
||||
args=" --help --path "
|
||||
commands=" fetch pull "
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
# Handle path completion
|
||||
if [[ ${prev} == -p ]] || [[ ${prev} == --path ]]; then
|
||||
OLDIFS=$IFS
|
||||
IFS='
|
||||
'
|
||||
COMPREPLY=( $(compgen -d -- "${cur}") )
|
||||
IFS=$OLDIFS
|
||||
else
|
||||
args="--help --path fetch pull"
|
||||
COMPREPLY=( $(compgen -W "${args}" -- "${cur}") )
|
||||
return
|
||||
fi
|
||||
|
||||
# Complete only one command
|
||||
for word in ${COMP_WORDS[*]}; do
|
||||
if [[ "$commands" == *" ${word} "* ]]; then
|
||||
COMPREPLY=( $(compgen -W "${args}" -- "${cur}") )
|
||||
return
|
||||
fi
|
||||
done
|
||||
COMPREPLY=( $(compgen -W "${commands} ${args}" -- "${cur}") )
|
||||
}
|
||||
|
||||
complete -o filenames -F _gis_completion gis
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue