commit - 2effce3b0dc82d59f8f0898b32efb2c50cb3b8cf
commit + 77ac985929d887789d3c0db452694866575d1e78
blob - f8528d3dbfd4a54d7d0aad3a43d8d2b106ac2ca3
blob + ce390faa5eaf1d8e86a324eb96855568e65181c7
--- scripts/dmenu_pass
+++ scripts/dmenu_pass
#/bin/sh
+dir="$HOME/.password-store"
+cache="$dir/.cache"
+
usage() {
echo "Usage: $0 test|paste|copy|login_enter|login_tab|paste_username|copy_username"
exit 1
echo "$1" | xclip -in -sel clipboard
}
+list() {
+ if [ "$cache" -nt "$dir" ]; then
+ cat "$cache"
+ elif [ -e "$dir/.gpg-id" ]; then
+ cd "$dir"
+ find . -type f -name '*.gpg' | sed 's/^\.\/\(.*\)\.gpg/\1/' | tee "$cache"
+ else
+ echo 'Password Store is empty'
+ fi
+}
+
mode=$1 # test, paste, copy, login_enter, login_tab
[ -z "$mode" ] && usage
-cd "$HOME/.password-store"
-name=$(find . -type f -name '*.gpg' | sed 's/^\.\/\(.*\)\.gpg/\1/' | dmenu -l 10 -p Password) || exit 1
+name=$(list | dmenu -l 10 -p Password) || exit 1
creds=$(pass show "$name") || exit 1
username=$(echo "$creds" | sed -n '/^username: /s///p')
password=$(echo "$creds" | sed -n '/^password: /s///p')