[PATCH] add custom bash completion for extensions
Lars Flitter
password-store at larsflitter.de
Tue Jul 17 22:42:17 CEST 2018
Bash completion now allows usage of extension commands.
To add extension commands to the list of commands append the PASSWORD_STORE_EXTENSION_COMMANDS variable with a leading space:
PASSWORD_STORE_EXTENSION_COMMANDS=+" COMMAND"
To complete after the command define a function like this:
__password_store_extension_complete_COMMAND() {
COMPREPLY+=($(compgen -W "-o --option" -- ${cur}))
_pass_complete_entries 1
}
---
src/completion/pass.bash-completion | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/completion/pass.bash-completion b/src/completion/pass.bash-completion
index 456485b..c59f558 100644
--- a/src/completion/pass.bash-completion
+++ b/src/completion/pass.bash-completion
@@ -81,8 +81,17 @@ _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
+ # To complete after an extension command define a function like this:
+ # __password_store_extension_complete_<COMMAND>() {
+ # COMPREPLY+=($(compgen -W "-o --option" -- ${cur}))
+ # _pass_complete_entries 1
+ # }
+ if type __password_store_extension_complete_${COMP_WORDS[1]} &> /dev/null ;then
+ __password_store_extension_complete_${COMP_WORDS[1]}
+ fi
+
local lastarg="${COMP_WORDS[$COMP_CWORD-1]}"
case "${COMP_WORDS[1]}" in
init)
--
2.18.0
More information about the Password-Store
mailing list