[PATCH] zshell completion

Jaime Ibar jaime at tchpc.tcd.ie
Tue Jul 17 11:49:40 CEST 2018


Hi,

some of our files stored in pass repo are named like

abc[01-02]_abcd[01-02]

so as brackets are not escaped, zshell completion fails with this error

_values:compvalues:11: invalid value definition: abc[01-02]_abcd[01-02]

Also, a hidden file .gitattributes is created when setting up the 
password-store repo for

the first time.

I wrote this patch to ignore .gitattributes file and escape brackets.

git diff
diff --git a/src/completion/pass.zsh-completion 
b/src/completion/pass.zsh-completion
index 27ce15a..a08809c 100644
--- a/src/completion/pass.zsh-completion
+++ b/src/completion/pass.zsh-completion
@@ -124,7 +124,7 @@ _pass_complete_entries_helper () {
         local IFS=$'\n'
         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):-""}
+     _values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o 
-name .gpg-id -o -name .gitattributes \) -prune -o $@ -print 2>/dev/null 
| sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#' -e 
's#\[#\\\[#g' -e 's#\]#\\\]#g' | sort):-""}
  }

  _pass_complete_entries_with_subdirs () {

I tried this patch and it worked for me. After hitting tab, brackets are 
correctly escaped and .gitattributes file is not showed

in completion list

pass ls abc\[01-02\]_abcd\[01-02\]

Thanks

Jaime

-- 

Jaime Ibar
High Performance & Research Computing, IS Services
Lloyd Building, Trinity College Dublin, Dublin 2, Ireland.
http://www.tchpc.tcd.ie/ | jaime at tchpc.tcd.ie
Tel: +353-1-896-3725



More information about the Password-Store mailing list