diff options
author | Lars Flitter <password-store@larsflitter.de> | 2018-07-18 15:17:45 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-07-26 22:45:59 +0200 |
commit | 6a6222eef23d25bec90015e49bd69c42062434ee (patch) | |
tree | b120a618a3cc9294652e73e3be86bf6fa067a552 | |
parent | e70b264c5ba1ccf7341aa90bdbf0573c9b13d17e (diff) |
Add custom bash completion for extensions
Bash completion now allows usage of extension commands.
(see pass.bash-completion for details)
-rw-r--r-- | src/completion/pass.bash-completion | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/completion/pass.bash-completion b/src/completion/pass.bash-completion index 456485b..bbe9d0c 100644 --- a/src/completion/pass.bash-completion +++ b/src/completion/pass.bash-completion @@ -81,7 +81,7 @@ _pass() { COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" - local commands="init ls find grep show insert generate edit rm mv cp git help version" + local commands="init ls find grep show insert generate edit rm mv cp git help version ${PASSWORD_STORE_EXTENSION_COMMANDS[*]}" if [[ $COMP_CWORD -gt 1 ]]; then local lastarg="${COMP_WORDS[$COMP_CWORD-1]}" case "${COMP_WORDS[1]}" in @@ -121,6 +121,17 @@ _pass() COMPREPLY+=($(compgen -W "init push pull config log reflog rebase" -- ${cur})) ;; esac + + # To add completion for an extension command define a function like this: + # __password_store_extension_complete_<COMMAND>() { + # COMPREPLY+=($(compgen -W "-o --option" -- ${cur})) + # _pass_complete_entries 1 + # } + # + # and add the command to the $PASSWORD_STORE_EXTENSION_COMMANDS array + if [[ " ${PASSWORD_STORE_EXTENSION_COMMANDS[*]} " == *" ${COMP_WORDS[1]} "* ]] && type "__password_store_extension_complete_${COMP_WORDS[1]}" &> /dev/null; then + "__password_store_extension_complete_${COMP_WORDS[1]}" + fi else COMPREPLY+=($(compgen -W "${commands}" -- ${cur})) _pass_complete_entries 1 |