From 1d209b896fc1dd2d12af2134081ab32ff84a1ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Si=C3=B4n=20le=20Roux?= Date: Thu, 3 Oct 2019 21:29:23 +0200 Subject: [PATCH] Don't suggest completions for git fork free-text arguments The --remote-name and --org parameters to git fork expect arguments which can be considered free text because the user has to suggest a name, so we can't provide suggestions there. If one of those two was the previous word then we clear completion suggestions until a free-text word has been entered, allowing the user to add their own input there. --- etc/hub.bash_completion.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/etc/hub.bash_completion.sh b/etc/hub.bash_completion.sh index f4a61a68..d4ca33d4 100644 --- a/etc/hub.bash_completion.sh +++ b/etc/hub.bash_completion.sh @@ -218,19 +218,30 @@ EOF esac } - # hub fork [--no-remote] [--remote-name] [--org] + # hub fork [--no-remote] [--remote-name REMOTE] [--org ORGANIZATION] _git_fork() { local i c=2 flags="--no-remote --remote-name --org" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in - --no-remote|--remote-name|--org) + --remote-name|--org) + ((c++)) + flags=${flags/$i/} + ;; + --no-remote) flags=${flags/$i/} ;; esac ((c++)) done - __gitcomp "$flags" + case "$prev" in + --remote-name|--org) + COMPREPLY=() + ;; + *) + __gitcomp "$flags" + ;; + esac } # hub pull-request [-f] [-m |-F |-i |] [-b ] [-h ] [-a ] [-M ] [-l ]