El mar, 02 abr 2019, Tobias Girstmair decĂa: > On Tue, Apr 02, 2019 at 01:09:44AM +0100, higuita wrote: > > Hi > > > > On Mon, 25 Mar 2019 11:36:32 -0300, OSiUX <[email protected]> wrote: > > > Adding -n or --notree: > > > > +1 to this, please merge this for everyone to be able to use it. > > +1 to the idea, but I have some proposals for improvement: > - this would be nice for `pass ls` as well (although it can be emulated > with `pass find ''`)
Hi. I never use `pass ls`, maybe because I have too many files :P
Work password-store:
1376 directories
1538 .gpg files
27 .gpg-id files
Personal password-store:
409 directories
367 .gpg files
1 .gpg-id files
Looking at the `ls` function, this call `cmd_show` and can receive several
options (qrcode|clip), maybe it's a very generic function.
Now I would prefer not to change the default behavior.
We would have to evaluate well what would be the best option.
> - having an environment variable for this would allow one to have no-tree
> as the default (can't alias a subcommand, or?)
This is very simple and I add it in a new patch.
Thanks for the idea, already added `export PASS_NOTREE=1` to my ~/.bashrc
I prefer to use the -notree option because it allows me to quickly (messy)
filter the results:
# pass find mysql | grep backup | grep db01 | grep tenant
Thanks everyone for the comments and suggestions :)
--
::
Osiris Alejandro Gomez (OSiUX) [email protected]
DC4495D2 0D5DD544 FC1AF00F B308A671 9237D36C
https://www.osiux.com/ https://www.gcoop.coop/
diff --git a/src/password-store.sh b/src/password-store.sh
index 284eabf..a6e0b0f 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -408,10 +408,39 @@ cmd_show() {
}
cmd_find() {
- [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..."
+ DEFAULT_PASS_NOTREE=0
+ local opts notree=0
+ opts="$($GETOPT -o n -l notree -n "$PROGRAM" -- "$@")"
+ local err=$?
+ eval set -- "$opts"
+ while true; do case $1 in
+ -n|--notree) notree="1"; shift ;;
+ --) shift; break ;;
+ esac done
+ [[ $# -ne 1 ]] && die "Usage: $PROGRAM $COMMAND [--notree,-n] pass-names..."
IFS="," eval 'echo "Search Terms: $*"'
local terms="*$(printf '%s*|*' "$@")"
+ local f
+ local c
+ tmpdir #Defines $SECURE_TMPDIR
+ local tmp_file=$(mktemp -u "$SECURE_TMPDIR/XXXXXX")
+
+ [[ -z "$PASS_NOTREE" ]] && PASS_NOTREE="$DEFAULT_PASS_NOTREE"
+ [[ "$PASS_NOTREE" -eq 1 ]] && notree=1
+
+ if [[ $notree -eq 0 ]]
+ then
tree -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g'
+ else
+ c=$(echo "$PREFIX" | wc -c)
+ let c++
+ find "$PREFIX" -follow -type d -iname "*${@}*" 2>/dev/null | while read f
+ do
+ find "$f" -follow -type f -iname '*.gpg' 2>/dev/null
+ done > "$tmp_file"
+ find "$PREFIX" -follow -type f -iname "*${@}*.gpg" 2>/dev/null >> "$tmp_file"
+ sort -u "$tmp_file" | sed 's/.gpg//g' | cut -c $c- && rm -f "$tmp_file"
+ fi
}
cmd_grep() {
signature.asc
Description: PGP signature
_______________________________________________ Password-Store mailing list [email protected] https://lists.zx2c4.com/mailman/listinfo/password-store
