<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>
</p>
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 12px;" lang="x-unicode">Hello people,
<br>
<br>
I added a couple of options on 'list/ls' command to make the
output friendler for a fuzzy search (like fzf). Combining this
commands is faster (at least in my case) to show passwords and you
don't even need to remember the full name.
<br>
<br>
<br>
The options are **--no-header** and **--plain** flags are added to
make the list command output friendlier to [fzf](<a
class="moz-txt-link-freetext"
href="https://github.com/junegunn/fzf">https://github.com/junegunn/fzf</a>).
<br>
<br>
Output looks like:
<br>
<br>
```
<br>
➜ pass --plain --no-header
<br>
b
<br>
a/2
<br>
a/1
<br>
cred1
<br>
I am a cred with lots of spaces
<br>
```
<br>
and the default output is:
<br>
```
<br>
➜ pass
<br>
Password Store
<br>
├── a
<br>
│ ├── 1
<br>
│ └── 2
<br>
├── b
<br>
├── cred1
<br>
└── I am a cred with lots of spaces
<br>
```
<br>
<br>
Having [fzf](<a class="moz-txt-link-freetext"
href="https://github.com/junegunn/fzf">https://github.com/junegunn/fzf</a>)
installed and executing `pass show $(pass --plain --no-header |
fzf)` will open the fuzzy finder to search password names. (I
wrote a [password-store zsh plugin](<a
class="moz-txt-link-freetext"
href="https://github.com/gmatheu/shell-plugins/blob/master/password-store/init.sh">https://github.com/gmatheu/shell-plugins/blob/master/password-store/init.sh</a>)
using antigen)
<br>
<br>
asciinema recording with usage -> <a
class="moz-txt-link-freetext"
href="https://asciinema.org/a/cwdgh4xfTNm6fr6SEnH3arPEm">https://asciinema.org/a/cwdgh4xfTNm6fr6SEnH3arPEm</a>
<br>
<br>
<br>
Hope this is useful.
<br>
<br>
Regards.
<br>
<br>
PS: I forked on gitlab.com -> <a class="moz-txt-link-freetext"
href="https://gitlab.com/gmatheu/password-store/merge_requests/1">https://gitlab.com/gmatheu/password-store/merge_requests/1</a>
<br>
<br>
-
<br>
<br>
Gonzalo Matheu
<br>
<br>
<br>
---
<br>
<br>
diff --git a/man/pass.1 b/man/pass.1
<br>
index a555dcb..7586308 100644
<br>
--- a/man/pass.1
<br>
+++ b/man/pass.1
<br>
@@ -74,12 +74,17 @@ the password store. If only one \fIgpg-id\fP
is given, and it is an empty string
<br>
then the current \fI.gpg-id\fP file for the specified
\fIsub-folder\fP (or root if
<br>
unspecified) is removed.
<br>
.TP
<br>
-\fBls\fP \fIsubfolder\fP
<br>
+\fBls\fP [ \fI--plain\fP ] \fIsubfolder\fP
<br>
List names of passwords inside the tree at
<br>
.I subfolder
<br>
by using the
<br>
.BR tree (1)
<br>
-program. This command is alternatively named \fBlist\fP.
<br>
+program. If \fI--plain\fP is specified it will show qualified
password names using
<br>
+.BR find (1)
<br>
+program instead of
<br>
+.BR tree (1)
<br>
+utility. When \fI--no-header\fP is used it will show only
password names without any header.
<br>
+This command is alternatively named \fBlist\fP.
<br>
.TP
<br>
\fBgrep\fP [\fIGREPOPTIONS\fP] \fIsearch-string\fP
<br>
Searches inside each decrypted password file for
\fIsearch-string\fP, and displays line
<br>
@@ -472,6 +477,7 @@ The location of the text editor used by
\fBedit\fP.
<br>
.BR xclip (1),
<br>
.BR wl-clipboard (1),
<br>
.BR qrencode (1).
<br>
+.BR find(1).
<br>
<br>
.SH AUTHOR
<br>
.B pass
<br>
diff --git a/src/password-store.sh b/src/password-store.sh
<br>
index 284eabf..5dbc61d 100755
<br>
--- a/src/password-store.sh
<br>
+++ b/src/password-store.sh
<br>
@@ -364,16 +364,19 @@ cmd_init() {
<br>
<br>
cmd_show() {
<br>
local opts selected_line clip=0 qrcode=0
<br>
- opts="$($GETOPT -o q::c:: -l qrcode::,clip:: -n "$PROGRAM" --
"$@")"
<br>
+ opts="$($GETOPT -o q::c:: -l qrcode::,clip::,plain,no-header
-n "$PROGRAM" -- "$@")"
<br>
local err=$?
<br>
eval set -- "$opts"
<br>
while true; do case $1 in
<br>
-q|--qrcode) qrcode=1; selected_line="${2:-1}"; shift 2
;;
<br>
-c|--clip) clip=1; selected_line="${2:-1}"; shift 2 ;;
<br>
+ --plain) plain=1; shift 1;;
<br>
+ --no-header) no_header=1; shift 1;;
<br>
--) shift; break ;;
<br>
esac done
<br>
<br>
- [[ $err -ne 0 || ( $qrcode -eq 1 && $clip -eq 1 ) ]]
&& die "Usage: $PROGRAM $COMMAND
[--clip[=line-number],-c[line-number]]
[--qrcode[=line-number],-q[line-number]] [pass-name]"
<br>
+ [[ $err -ne 0 || ( $qrcode -eq 1 && $clip -eq 1 ) ]]
&& \
<br>
+ die "Usage: $PROGRAM $COMMAND
[--clip[=line-number],-c[line-number]]
[--qrcode[=line-number],-q[line-number]] [--plain] [--no-header]
[pass-name]"
<br>
<br>
local pass
<br>
local path="$1"
<br>
@@ -394,12 +397,18 @@ cmd_show() {
<br>
fi
<br>
fi
<br>
elif [[ -d $PREFIX/$path ]]; then
<br>
- if [[ -z $path ]]; then
<br>
- echo "Password Store"
<br>
- else
<br>
- echo "${path%\/}"
<br>
+ if [[ $no_header -ne 1 ]]; then
<br>
+ if [[ -z $path ]]; then
<br>
+ echo "Password Store"
<br>
+ else
<br>
+ echo "${path%\/}"
<br>
+ fi
<br>
+ fi
<br>
+ if [[ $plain -eq 1 ]]; then
<br>
+ find "$PREFIX/$path" -name '*.gpg' | sed -E
"s#$PREFIX/##g; s/\.gpg//g"
<br>
+ else
<br>
+ 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
<br>
fi
<br>
- 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
<br>
elif [[ -z $path ]]; then
<br>
die "Error: password store is empty. Try \"pass init\"."
<br>
else
<br>
diff --git a/tests/t0020-show-tests.sh b/tests/t0020-show-tests.sh
<br>
index a4b782f..0d62ae1 100755
<br>
--- a/tests/t0020-show-tests.sh
<br>
+++ b/tests/t0020-show-tests.sh
<br>
@@ -19,4 +19,42 @@ test_expect_success 'Test "show" of nonexistant
password' '
<br>
test_must_fail "$PASS" show cred2
<br>
'
<br>
<br>
+test_expect_success 'Show list as a tree' '
<br>
+ "$PASS" insert -e "a/1"<<<"a1" &&
<br>
+ "$PASS" insert -e "a/2"<<<"a2" &&
<br>
+ "$PASS" insert -e "b"<<<"b" &&
<br>
+ "$PASS" list | grep -q ".*a" &&
<br>
+ "$PASS" list | grep -q ".*1" &&
<br>
+ "$PASS" list | grep -q ".*b"
<br>
+'
<br>
+
<br>
+test_expect_success 'Show plain list' '
<br>
+ "$PASS" insert -e "a/1"<<<"a1" &&
<br>
+ "$PASS" insert -e "a/2"<<<"a2" &&
<br>
+ "$PASS" insert -e "b"<<<"b" &&
<br>
+ "$PASS" list --plain | grep -q "a/1" &&
<br>
+ "$PASS" list --plain | grep -q "a/2" &&
<br>
+ "$PASS" list --plain | grep -q "b"
<br>
+'
<br>
+
<br>
+test_expect_success 'Show plain list on path' '
<br>
+ "$PASS" insert -e "a/1"<<<"a1" &&
<br>
+ "$PASS" insert -e "a/2"<<<"a2" &&
<br>
+ "$PASS" insert -e "b"<<<"b" &&
<br>
+ "$PASS" list --plain a | grep -q "a/1" &&
<br>
+ "$PASS" list --plain a | grep -q "a/2" &&
<br>
+ "$PASS" list --plain a | grep -c "a/" | grep "2" &&
<br>
+ "$PASS" list --plain a | grep -c "b" | grep "0"
<br>
+'
<br>
+
<br>
+test_expect_success 'Shows header by default' '
<br>
+ "$PASS" insert -e "a/1"<<<"a1" &&
<br>
+ "$PASS" list | grep "Password Store"
<br>
+'
<br>
+
<br>
+test_expect_success 'Do not show header' '
<br>
+ "$PASS" insert -e "a/1"<<<"a1" &&
<br>
+ "$PASS" list --no-header | grep -c "Password Store" | grep
"0"
<br>
+'
<br>
+
<br>
test_done
<br>
<div class="moz-txt-sig"><span class="moz-txt-tag">-- <br>
</span>2.17.1
<br>
<br>
<br>
</div>
</div>
</body>
</html>