[PATCH] Improve zsh completion for multiple repositories
Tom Whitwell
tom at whi.tw
Mon Apr 4 13:33:59 UTC 2022
Rather than stripping the called program from $curcontext, keep it
and append the pass command to it.
The `zstyle` command can then be amended with a wildcard, so
all completions have the 'prefix' context. Without this, subcommand
completion still operates against the 'main' password store repo.
---
src/completion/pass.zsh-completion | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/completion/pass.zsh-completion b/src/completion/pass.zsh-completion
index d911e12..71d215a 100644
--- a/src/completion/pass.zsh-completion
+++ b/src/completion/pass.zsh-completion
@@ -12,7 +12,7 @@
# If you use multiple repositories, you can configure completion like this:
#
# compdef _pass workpass
-# zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
+# zstyle ':completion::complete:workpass:*:' prefix "$HOME/work/pass"
# workpass() {
# PASSWORD_STORE_DIR=$HOME/work/pass pass $@
# }
@@ -23,7 +23,7 @@ _pass () {
if (( CURRENT > 2)); then
cmd=${words[2]}
# Set the context for the subcommand.
- curcontext="${curcontext%:*:*}:pass-$cmd"
+ curcontext="${curcontext%:*}:pass-$cmd"
# Narrow the range of words we are looking at to exclude `pass'
(( CURRENT-- ))
shift words
--
2.32.0 (Apple Git-132)
More information about the Password-Store
mailing list