[PATCH] Fix zsh completion for multiple repositories

Yong-Siang Shih shaform at gmail.com
Tue Jan 1 17:11:07 CET 2019


Hi all,

I found that in zsh, even if we set the following according to the
instructions, the completion still doesn't work for subcommands:

> zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"

This patch fixes this and allow the subcommand to have correct completions.

Best,
Yong-Siang Shih

diff --git src/completion/pass.zsh-completion
src/completion/pass.zsh-completion
index 27ce15a..c0f5b64 100644
--- src/completion/pass.zsh-completion
+++ src/completion/pass.zsh-completion
@@ -20,6 +20,8 @@

 _pass () {
        local cmd
+       local rootcontext
+       rootcontext=$curcontext
        if (( CURRENT > 2)); then
                cmd=${words[2]}
                # Set the context for the subcommand.
@@ -123,7 +125,7 @@ _pass_cmd_show () {
 _pass_complete_entries_helper () {
        local IFS=$'\n'
        local prefix
-       zstyle -s ":completion:${curcontext}:" prefix prefix ||
prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
+       zstyle -s ":completion:${rootcontext}:" prefix prefix ||
prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
        _values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name
.gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##"
-e 's#\.gpg##' -e 's#\\#\\\\#' | sort):-""}
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20190101/a7097f6c/attachment.html>


More information about the Password-Store mailing list