This dump command will decrypt all passwords and print them.
For example if we have the following password store:

$ pass ls
 Password Store
 └── www
     └── google.com
     └── att.com

Then `pass dump` would show

$ pass dump
[www/google.com]
mygooglepassword

[www/att.com]
myat&tpassword

I find this useful for piping the output into vim and then
searching the content for information I've stored.
---
 man/pass.1            |  3 +++
 src/password-store.sh | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/man/pass.1 b/man/pass.1
index 71bfc7e..796f41d 100644
--- a/man/pass.1
+++ b/man/pass.1
@@ -166,6 +166,9 @@ is set to \fItrue\fP, then all commits will be signed using 
\fIuser.signingkey\f
 default git signing key. This config key may be turned on using:
 .B `pass git config --bool --add pass.signcommits true`
 .TP
+\fBdump\fP
+Decrypt all passwords and print them to stdout.
+.TP
 \fBhelp\fP
 Show usage message.
 .TP
diff --git a/src/password-store.sh b/src/password-store.sh
index 081057a..132bb43 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -282,6 +282,8 @@ cmd_usage() {
            $PROGRAM git git-command-args...
                If the password store is a git repository, execute a git command
                specified by git-command-args.
+           $PROGRAM dump
+               Decrypt all passwords and print them to stdout.
            $PROGRAM help
                Show this text.
            $PROGRAM version
@@ -380,6 +382,17 @@ cmd_show() {
        fi
 }
 
+cmd_dump() {
+       local passfile
+       pushd $PREFIX > /dev/null
+       find * -type f -name '*.gpg' | while read passfile; do
+               echo "[${passfile%.gpg}]"
+               $GPG "${GPG_OPTS[@]}" -d "$passfile"
+               echo -e "\n"
+       done
+       popd > /dev/null
+}
+
 cmd_find() {
        [[ -z "$@" ]] && die "Usage: $PROGRAM $COMMAND pass-names..."
        IFS="," eval 'echo "Search Terms: $*"'
@@ -669,6 +682,7 @@ case "$1" in
        rename|mv) shift;               cmd_copy_move "move" "$@" ;;
        copy|cp) shift;                 cmd_copy_move "copy" "$@" ;;
        git) shift;                     cmd_git "$@" ;;
+       dump) shift;                    cmd_dump ;;
        *)                              cmd_extension_or_show "$@" ;;
 esac
 exit 0
-- 
2.7.4

_______________________________________________
Password-Store mailing list
[email protected]
https://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to