summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Richter <br@waldteufel.eu>2016-02-06 21:50:44 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-02-06 22:20:57 +0100
commit675a002e3f9f84e07418b15105af3ab8049eb443 (patch)
treedc6131d3105a5ca0ca2746b815ed679ee93e159d
parent4b0b6ac82f0c372405cadd921c9d5a1d9927788f (diff)
downloadpass-675a002e3f9f84e07418b15105af3ab8049eb443.tar.gz
pass-675a002e3f9f84e07418b15105af3ab8049eb443.tar.bz2
pass-675a002e3f9f84e07418b15105af3ab8049eb443.zip
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.
Diffstat (limited to '')
-rw-r--r--src/completion/pass.zsh-completion12
1 files changed, 11 insertions, 1 deletions
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):-""}
}