From 675a002e3f9f84e07418b15105af3ab8049eb443 Mon Sep 17 00:00:00 2001 From: Benjamin Richter Date: Sat, 6 Feb 2016 21:50:44 +0100 Subject: zsh-completion: add prefix zstyle This option can be used to select a different pass repository for completion. A configuration example is given inside the completion file. --- src/completion/pass.zsh-completion | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/completion/pass.zsh-completion b/src/completion/pass.zsh-completion index 6a33d75..27ce15a 100644 --- a/src/completion/pass.zsh-completion +++ b/src/completion/pass.zsh-completion @@ -9,6 +9,15 @@ # This file is licensed under the GPLv2+. Please see COPYING for more information. +# If you use multiple repositories, you can configure completion like this: +# +# compdef _pass workpass +# zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass" +# workpass() { +# PASSWORD_STORE_DIR=$HOME/work/pass pass $@ +# } + + _pass () { local cmd if (( CURRENT > 2)); then @@ -113,7 +122,8 @@ _pass_cmd_show () { } _pass_complete_entries_helper () { local IFS=$'\n' - local prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}" + local prefix + zstyle -s ":completion:${curcontext}:" 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):-""} } -- cgit v1.2.3