aboutsummaryrefslogtreecommitdiffstats
path: root/misc/completion/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'misc/completion/zsh')
-rw-r--r--misc/completion/zsh/git-bug32
1 files changed, 30 insertions, 2 deletions
diff --git a/misc/completion/zsh/git-bug b/misc/completion/zsh/git-bug
index e7cbe9a9..3ddfddb8 100644
--- a/misc/completion/zsh/git-bug
+++ b/misc/completion/zsh/git-bug
@@ -1,4 +1,4 @@
-#compdef _git-bug git-bug
+#compdef git-bug
# zsh completion for git-bug -*- shell-script -*-
@@ -86,7 +86,24 @@ _git-bug()
return
fi
+ local activeHelpMarker="_activeHelp_ "
+ local endIndex=${#activeHelpMarker}
+ local startIndex=$((${#activeHelpMarker}+1))
+ local hasActiveHelp=0
while IFS='\n' read -r comp; do
+ # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
+ if [ "${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
+ __git-bug_debug "ActiveHelp found: $comp"
+ comp="${comp[$startIndex,-1]}"
+ if [ -n "$comp" ]; then
+ compadd -x "${comp}"
+ __git-bug_debug "ActiveHelp will need delimiter"
+ hasActiveHelp=1
+ fi
+
+ continue
+ fi
+
if [ -n "$comp" ]; then
# If requested, completions are returned with a description.
# The description is preceded by a TAB character.
@@ -94,7 +111,7 @@ _git-bug()
# We first need to escape any : as part of the completion itself.
comp=${comp//:/\\:}
- local tab=$(printf '\t')
+ local tab="$(printf '\t')"
comp=${comp//$tab/:}
__git-bug_debug "Adding completion: ${comp}"
@@ -103,6 +120,17 @@ _git-bug()
fi
done < <(printf "%s\n" "${out[@]}")
+ # Add a delimiter after the activeHelp statements, but only if:
+ # - there are completions following the activeHelp statements, or
+ # - file completion will be performed (so there will be choices after the activeHelp)
+ if [ $hasActiveHelp -eq 1 ]; then
+ if [ ${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
+ __git-bug_debug "Adding activeHelp delimiter"
+ compadd -x "--"
+ hasActiveHelp=0
+ fi
+ fi
+
if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
__git-bug_debug "Activating nospace."
noSpace="-S ''"