diff options
author | Kevin Locke <kevin@kevinlocke.name> | 2021-03-11 13:55:19 -0700 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2021-03-11 23:43:59 +0100 |
commit | 27305719685f8fe04b668336884db65aae25060b (patch) | |
tree | d5053b3e73f052715229dab414f79eda8b424003 | |
parent | 9e283f2c34feb9812d5084a256ef932fe86013bd (diff) |
Fix bash-completion script
The previous bash-completion script was non-functional. Replace it with
a functional bash-completion script generated using:
register-python-argcomplete3 git-phab | sed '
s/_python_argcomplete/_git_phab/
s/"$1"/git-phab/
s/COMP_LINE="$COMP_LINE"/COMP_LINE="${COMP_LINE\/git phab\/git-phab}"/'
The first replacement renames the completion function to _git_phab,
which is required by the bash-completion script for git to complete `git
phab`.
The second replacement invokes git-phab to perform the completion,
rather than the first function argument, since the git bash-completion
script does not pass any arguments to the completion function.
The third replaces 'git phab' with 'git-phab' in $COMP_LINE so that
argcomplete can recognize the script name when parsing $COMP_LINE.
Note: It would be possible to Build-Depend on python3-argcomplete and
generate this script during build. (See diffoscope for an example.)
However, making the above changes would be fragile, since the output of
register-python-argcomplete3 may change arbitrarily, so this patch uses
the edited script.
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
-rw-r--r-- | debian/bash_completion.d/git-phab | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/debian/bash_completion.d/git-phab b/debian/bash_completion.d/git-phab index 6603f72..e9a3ea5 100644 --- a/debian/bash_completion.d/git-phab +++ b/debian/bash_completion.d/git-phab @@ -1,7 +1,22 @@ -function _git_phab() -{ - COMP_WORDS=(git-phab ${COMP_WORDS[@]:2}) - COMP_CWORD=$((COMP_CWORD - 1)) - COMP_LINE=${COMP_LINE/git phab/git-phab} - _python_argcomplete_global git-phab +_git_phab() { + local IFS=$'\013' + local SUPPRESS_SPACE=0 + if compopt +o nospace 2> /dev/null; then + SUPPRESS_SPACE=1 + fi + COMPREPLY=( $(IFS="$IFS" \ + COMP_LINE="${COMP_LINE/git phab/git-phab}" \ + COMP_POINT="$COMP_POINT" \ + COMP_TYPE="$COMP_TYPE" \ + _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" \ + _ARGCOMPLETE=1 \ + _ARGCOMPLETE_SUPPRESS_SPACE=$SUPPRESS_SPACE \ + git-phab 8>&1 9>&2 1>/dev/null 2>/dev/null) ) + if [[ $? != 0 ]]; then + unset COMPREPLY + elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "$COMPREPLY" =~ [=/:]$ ]]; then + compopt -o nospace + fi +} +complete -o nospace -o default -F _git_phab "git-phab" |