[pass] [PATCH] Added fuzzy completion to bash. set PASSWORD_STORE_FUZZY environment variable to choose the fuzzy command.

pcre pcre at gmx.de
Wed Oct 7 15:12:00 CEST 2015


---
 src/completion/pass.bash-completion | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/completion/pass.bash-completion b/src/completion/pass.bash-completion
index efd4b70..9157f2f 100644
--- a/src/completion/pass.bash-completion
+++ b/src/completion/pass.bash-completion
@@ -65,6 +65,19 @@ _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 fuzzycmd="${PASSWORD_STORE_FUZZY}"
+	local pwdir="${PASSWORD_STORE_DIR:-$HOME/.password-store/}"
+	local stringsize="${#pwdir}"
+	let "stringsize+=1"
+	trigger="**"
+
+	if [[ ${COMP_WORDS[COMP_CWORD]} == "$trigger" ]]; then
+		COMPREPLY=($(find "$pwdir" -name "*.gpg" | \
+		cut -c "$stringsize"- |	sed -e 's/\(.*\)\.gpg/\1/' | \
+		"$fuzzycmd" | tr "\n" ' '))
+		return 0
+	fi
+
 	if [[ $COMP_CWORD -gt 1 ]]; then
 		local lastarg="${COMP_WORDS[$COMP_CWORD-1]}"
 		case "${COMP_WORDS[1]}" in
-- 
2.1.4



More information about the Password-Store mailing list