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 {
|
function _gis_completion {
|
||||||
|
args=" --help --path "
|
||||||
|
commands=" fetch pull "
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
|
# Handle path completion
|
||||||
if [[ ${prev} == -p ]] || [[ ${prev} == --path ]]; then
|
if [[ ${prev} == -p ]] || [[ ${prev} == --path ]]; then
|
||||||
OLDIFS=$IFS
|
OLDIFS=$IFS
|
||||||
IFS='
|
IFS='
|
||||||
'
|
'
|
||||||
COMPREPLY=( $(compgen -d -- "${cur}") )
|
COMPREPLY=( $(compgen -d -- "${cur}") )
|
||||||
IFS=$OLDIFS
|
IFS=$OLDIFS
|
||||||
else
|
return
|
||||||
args="--help --path fetch pull"
|
|
||||||
COMPREPLY=( $(compgen -W "${args}" -- "${cur}") )
|
|
||||||
fi
|
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
|
complete -o filenames -F _gis_completion gis
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue