diff options
author | Michael Muré <batolettre@gmail.com> | 2022-08-23 15:02:41 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-08-23 15:09:31 +0200 |
commit | 8d11e620a3d663cf21a62910d0f3961a8aff4be1 (patch) | |
tree | 17dc3df82229eea5c3500e2bd8448060dc1ae849 /misc/completion/zsh | |
parent | 5a70e8b3a2e0fe3d1a1dcd4c24bb6bf64633cb7f (diff) | |
download | git-bug-8d11e620a3d663cf21a62910d0f3961a8aff4be1.tar.gz |
webui: add a flag to log handling errors
Diffstat (limited to 'misc/completion/zsh')
-rw-r--r-- | misc/completion/zsh/git-bug | 32 |
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 ''" |