Fix completion after a command-line flag.
Before: yadm checkout -f <TAB> # Completes filenames. yadm checkout --yadm-dir <TAB> # Completes filenames. After: yadm checkout -f <TAB> # Completes branch names. yadm checkout --yadm-dir <TAB> # Completes filenames.
This commit is contained in:
parent
09a018ea5a
commit
60e0fbbf42
1 changed files with 4 additions and 2 deletions
|
@ -60,15 +60,17 @@ if declare -F _git > /dev/null; then
|
|||
;;
|
||||
esac
|
||||
|
||||
local yadm_switches=( $(yadm introspect switches 2>/dev/null) )
|
||||
|
||||
# this condition is so files are completed properly for --yadm-xxx options
|
||||
if [[ ! "$penultimate" =~ ^- ]]; then
|
||||
if [[ " ${yadm_switches[*]} " != *" $penultimate "* ]]; then
|
||||
# TODO: somehow solve the problem with [--yadm-xxx option] being
|
||||
# incompatible with what git expects, namely [--arg=option]
|
||||
_git
|
||||
fi
|
||||
if [[ "$current" =~ ^- ]]; then
|
||||
local matching
|
||||
matching=$(compgen -W "$(yadm introspect switches 2>/dev/null)" -- "$current")
|
||||
matching=$(compgen -W "${yadm_switches[*]}" -- "$current")
|
||||
__gitcompappend "$matching"
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue