<div dir="ltr"><br><div>FYI, What follows is the zsh function I use to search my password store based on 'find.' I've tuned it to match any part of directories and stores (case insensitively), but not the gpg extension or the password store path or git directory. sed is used to prune the .gpg extension from store files.</div><div><br></div><div>Von</div><div><br></div><div><br></div><div><div># Search passwords for string and return matches, one per line</div><div>search_pass() {</div><div> local store="${PASSWORD_STORE_DIR:-$HOME/.password-store}"</div><div><br></div><div> if test $# -ne 1 ; then</div><div> echo "Usage: $0 <search_string>" 1>&2</div><div> return 1</div><div> fi</div><div><br></div><div> # Change dir to store so we can run 'find .' and not match</div><div> # on password store directory.</div><div> pushd -q "${store}"</div><div><br></div><div> # All arguments escaped and joined into one string</div><div> search_string="${(j. .)${(q)@}}" ; shift</div><div><br></div><div> # Find first clause prunes .git/ directory</div><div> # Second clause matches full paths with matching directory components</div><div> # Third clause matches any part of filename, ignoring .gpg suffix</div><div> # -iname and -ipath are case-insensitive</div><div> # sed command strips path prefix and .gpg suffix</div><div> find . -type d -name .git -prune \</div><div> -o -ipath "*/*${search_string}*/*" -type f -print \</div><div> -o -iname "*${search_string}*.gpg" -type f -print \</div><div> | sed -e "s#./##" -e 's#\.gpg$##' | sort</div><div> popd -q</div><div>}</div><div><br></div></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 30, 2015 at 6:27 AM Lenz Weber <<a href="mailto:mail@lenzw.de">mail@lenzw.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 29.07.2015 um 12:57 schrieb nfb:<br>
> But...<br>
><br>
><br>
> » tree -C -l --noreport -P 'gpg*' --prune --matchdirs --ignore-case<br>
> PASSDIR/<br>
> PASSDIR/<br>
> ├── GPG<br>
> │ ├── firstkey.gpg<br>
> │ └── secondkey.gpg<br>
> └── homeserver<br>
> └── gpgkey.gpg<br>
><br>
><br>
> which is good...<br>
><br>
> Now this seems to be like this because in the pass script, the line<br>
> preceding the tree command defines the 'terms' variable, which adds<br>
> an asterisk in front of the parameters:<br>
><br>
> local terms="*$(printf '%s*|*' "$@")"<br>
><br>
> Maybe the culprit is here, but i can't figure out how to test it right<br>
> now...<br>
><br>
<br>
Such a solution would only search at the beginning of a word - I doubt thats what is intended by the search command.<br>
<br>
>> So to fix this without meddling with tree, we would need some awk<br>
>> magic, and that could get a bit ugly.<br>
>> Anyone got a better solution?<br>
> What about not using .gpg extension at all within the password-store?<br>
><br>
I doubt that change would be accepted - not only would it change a paradigma of pass, it would also be incompatible to all existing isntallations.<br>
_______________________________________________<br>
Password-Store mailing list<br>
<a href="mailto:Password-Store@lists.zx2c4.com" target="_blank">Password-Store@lists.zx2c4.com</a><br>
<a href="http://lists.zx2c4.com/mailman/listinfo/password-store" rel="noreferrer" target="_blank">http://lists.zx2c4.com/mailman/listinfo/password-store</a><br>
</blockquote></div>