Show All Files with `tree`

Chad Voegele cavoegele at gmail.com
Tue Aug 27 14:40:26 CEST 2019


Hi,

I use pass to store passwords for password-protected ssh keys. I store the
password under a path matching the path to the key. For the key
`~/.ssh/id_rsa`, I store the password at `$PASS_ROOT/$HOME/.ssh/id_rsa`.
With `pass list` and `pass find`, this path is not shown by `pass` because
`-a` is not passed to `tree`.

There are two options for patches that I would like to propose. The first
passes `-a` to `tree` with a catch to ignore the special `.gpg-id` file.
The second allows the user to specify additional `tree` arguments with an
environment variable.

Please let me know if you have any questions or suggestions.

Thanks!
Chad

>From f82769d8dbcaa053dac205f763328f957d57ffd0 Mon Sep 17 00:00:00 2001
From: Chad Voegele <cavoegele at gmail.com>
Date: Mon, 26 Aug 2019 20:00:14 -0700
Subject: [PATCH] Append '-a' to tree args to show all files

---
 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 1d119f2..37f7f31 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -399,7 +399,7 @@ cmd_show() {
  else
  echo "${path%\/}"
  fi
- tree -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed -E
's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but
keep colors
+ tree -C -l --noreport -a -I '.gpg-id' "$PREFIX/$path" | 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
@@ -411,7 +411,7 @@ cmd_find() {
  [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..."
  IFS="," eval 'echo "Search Terms: $*"'
  local terms="*$(printf '%s*|*' "$@")"
- 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'
+ tree -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case
-a -I '.gpg-id' "$PREFIX" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?(
->|$)/\1\2/g'
 }

 cmd_grep() {
-- 
2.22.0

>From 620b6b72d3484a2b22b9f251b0a873cf643c7738 Mon Sep 17 00:00:00 2001
From: Chad Voegele <cavoegele at gmail.com>
Date: Mon, 26 Aug 2019 20:03:53 -0700
Subject: [PATCH] Allow user specified tree arguments

---
 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 1d119f2..38aff71 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -399,7 +399,7 @@ cmd_show() {
  else
  echo "${path%\/}"
  fi
- tree -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed -E
's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but
keep colors
+ tree -C -l --noreport $PASSWORD_STORE_TREE_OPTS "$PREFIX/$path" | 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
@@ -411,7 +411,7 @@ cmd_find() {
  [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..."
  IFS="," eval 'echo "Search Terms: $*"'
  local terms="*$(printf '%s*|*' "$@")"
- 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'
+ tree -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case
$PASSWORD_STORE_TREE_OPTS "$PREFIX" | tail -n +2 | sed -E
's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g'
 }

 cmd_grep() {
-- 
2.22.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20190827/1525ca63/attachment.html>


More information about the Password-Store mailing list