From daniel.mach at suse.com Fri May 20 13:10:03 2022 From: daniel.mach at suse.com (Daniel Mach) Date: Fri, 20 May 2022 15:10:03 +0200 Subject: [PATCH] Display only *.gpg files in list and find commands Message-ID: <20220520131003.17801-1-daniel.mach@suse.com> If the password store lives in a git repo, it frequently contains extra files such as README.md. Pass shouldn't display these files because they do not contain secrets. --- src/password-store.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/password-store.sh b/src/password-store.sh index 22e818f..662bb31 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -402,7 +402,7 @@ cmd_show() { else echo "${path%\/}" fi - tree -N -C -l --noreport "$PREFIX/$path" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors + tree -N -C -l --noreport -P '*.gpg' "$PREFIX/$path" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors elif [[ -z $path ]]; then die "Error: password store is empty. Try \"pass init\"." else @@ -413,7 +413,7 @@ cmd_show() { cmd_find() { [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..." IFS="," eval 'echo "Search Terms: $*"' - local terms="*$(printf '%s*|*' "$@")" + local terms="*$(printf '%s*.gpg|*' "$@")" tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' } -- 2.36.1 From koelblandreas at freenet.de Tue May 24 18:15:06 2022 From: koelblandreas at freenet.de (koelblandreas at freenet.de) Date: Tue, 24 May 2022 20:15:06 +0200 Subject: [PATCH] Add option --flat Message-ID: <20220524181506.21597-1-koelblandreas@freenet.de> From: Andreas K?lbl Support an computable way to find passwords. There is no need for external tools to do so. --- src/password-store.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/password-store.sh b/src/password-store.sh index 22e818f..d5001bd 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -282,8 +282,8 @@ cmd_usage() { Selectively reencrypt existing passwords using new gpg-id. $PROGRAM [ls] [subfolder] List passwords. - $PROGRAM find pass-names... - List passwords that match pass-names. + $PROGRAM find [--flat] pass-names... + List passwords that match pass-names and optionally print it in a computable format. $PROGRAM [show] [--clip[=line-number],-c[line-number]] pass-name Show existing password and optionally put it on the clipboard. If put on the clipboard, it will be cleared in $CLIP_TIME seconds. @@ -412,9 +412,19 @@ cmd_show() { cmd_find() { [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..." - IFS="," eval 'echo "Search Terms: $*"' + local opts flat="0" + case $1 in + -f|--flat) flat=1; shift ;; + --) shift; break ;; + esac + local terms="*$(printf '%s*|*' "$@")" local terms="*$(printf '%s*|*' "$@")" - tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' + if [ $flat -eq 0 ]; then + IFS="," eval 'echo "Search Terms: $*"' + tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' + else + tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' | sed -E 's/???(.*)/\1/' | tr '\n' '/' | tr -d ' ' | rev | cut -c2- | rev | xargs echo | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | sed "s/\x0f//g" + fi } cmd_grep() { -- 2.35.1 From koelblandreas at freenet.de Tue May 24 18:35:07 2022 From: koelblandreas at freenet.de (koelblandreas at freenet.de) Date: Tue, 24 May 2022 20:35:07 +0200 Subject: [PATCH] Add option --flat In-Reply-To: <20220524181506.21597-1-koelblandreas@freenet.de> References: <20220524181506.21597-1-koelblandreas@freenet.de> Message-ID: <20220524183507.25932-1-koelblandreas@freenet.de> From: Andreas K?lbl Support an computable way to find passwords. This avoids the use of additional tools. By adding the flag --flat after pass find it prints the path of found passwords without colors, indentions or special characters. --- src/password-store.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/password-store.sh b/src/password-store.sh index 22e818f..6c90f19 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -282,8 +282,8 @@ cmd_usage() { Selectively reencrypt existing passwords using new gpg-id. $PROGRAM [ls] [subfolder] List passwords. - $PROGRAM find pass-names... - List passwords that match pass-names. + $PROGRAM find [--flat] pass-names... + List passwords that match pass-names and optionally print it without colors, indentions or special characters. $PROGRAM [show] [--clip[=line-number],-c[line-number]] pass-name Show existing password and optionally put it on the clipboard. If put on the clipboard, it will be cleared in $CLIP_TIME seconds. @@ -412,9 +412,18 @@ cmd_show() { cmd_find() { [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..." - IFS="," eval 'echo "Search Terms: $*"' + local opts flat="0" + case $1 in + -f|--flat) flat=1; shift ;; + --) shift; break ;; + esac local terms="*$(printf '%s*|*' "$@")" - tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' + if [ $flat -eq 0 ]; then + IFS="," eval 'echo "Search Terms: $*"' + tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' + else + tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' | sed -E 's/???(.*)/\1/' | tr '\n' '/' | tr -d ' ' | rev | cut -c2- | rev | xargs echo | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | sed "s/\x0f//g" + fi } cmd_grep() { -- 2.35.1 From koelblandreas at freenet.de Sat May 28 05:20:50 2022 From: koelblandreas at freenet.de (koelblandreas at freenet.de) Date: Sat, 28 May 2022 07:20:50 +0200 Subject: [PATCH] Add option --flat In-Reply-To: <20220524183507.25932-1-koelblandreas@freenet.de> References: <20220524183507.25932-1-koelblandreas@freenet.de> Message-ID: <20220528052050.32485-1-koelblandreas@freenet.de> From: Andreas K?lbl Support a computable way to find passwords. Avoid the use of additional tools. By adding the flag --flat after "pass find" it prints paths of found passwords without colors or indentions. --- src/password-store.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/password-store.sh b/src/password-store.sh index 22e818f..ab41ba4 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -282,8 +282,8 @@ cmd_usage() { Selectively reencrypt existing passwords using new gpg-id. $PROGRAM [ls] [subfolder] List passwords. - $PROGRAM find pass-names... - List passwords that match pass-names. + $PROGRAM find [--flat] pass-names... + List passwords that match pass-names and optionally print it without colors, indentions or special characters. $PROGRAM [show] [--clip[=line-number],-c[line-number]] pass-name Show existing password and optionally put it on the clipboard. If put on the clipboard, it will be cleared in $CLIP_TIME seconds. @@ -412,9 +412,18 @@ cmd_show() { cmd_find() { [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..." - IFS="," eval 'echo "Search Terms: $*"' + local opts flat="0" + case $1 in + -f|--flat) flat=1; shift ;; + --) shift; break ;; + esac local terms="*$(printf '%s*|*' "$@")" - tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' + if [ $flat -eq 0 ]; then + IFS="," eval 'echo "Search Terms: $*"' + tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' + else + tree -f -N -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E '/\.gpg/!d' | sed -E 's/?[?]*//g' | sed -E 's/[?]*//g' | sed -E 's/?[?]*//g' | sed -E 's/?//g' | sed -E "s|${PREFIX}/||g"| sed -E 's/\.gpg//g' | tr -d ' ' + fi } cmd_grep() { -- 2.35.1