Hi everybody! This is my first patch por pass. Adding -n or --notree:
# pass find foo -n Search Terms: foo bar-foo bar/foo foo-bar foo/bar # pass find bar -notree Search Terms: bar bar-foo bar/foo foo-bar foo/bar Quick help: # pass find Usage: pass find [--notree,-n] pass-names... I hope it will be useful for other console ninja users. -- :: 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..0dc753b 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -408,10 +408,35 @@ cmd_show() {
}
cmd_find() {
- [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..."
+ 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")
+
+ 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
