[PATCH] Add option --flat
Magnus Sandberg
mem at fallback.netnod.se
Tue Jul 19 09:37:50 UTC 2022
Hi,
After a few minutes of manual testing at my shell prompt, I guess this
one does the same;
find ${PREFIX} -type f -name '*.gpg' | grep -i "${terms}" \
| sed -E "s|^${PREFIX}/||" | sed -E 's/\.gpg$//' | sort
Assuming that 'grep -i "${terms}"' would give the same result as
'tree ... -P "${terms%|*}" ...'
Regards,
// mem
On 2022-07-18 at 14:17 CEST, koelblandreas at freenet.de wrote:
> From: Andreas Kölbl <koelblandreas at gentoo.org>
>
> 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 | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/src/password-store.sh b/src/password-store.sh
> index a0dcf2e..a4e84fc 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 terms="*$(printf '%s*|*' "$@")"
> - tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g'
> + local opts flat="0"
> + case $1 in
> + -f|--flat) flat=1; shift ;;
> + --) shift; break ;;
> + esac
> + local terms="*$(printf '%s*|*' "$@")"
> + 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() {
More information about the Password-Store
mailing list