diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-05 20:06:39 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-05 20:46:47 +1200 |
commit | c8ab406749124d2e762ad5cf53963070113afd0f (patch) | |
tree | 54c9721a06957ebe7098a211eea803b0230c0f5d /bin/dmp.sh | |
parent | Handle POSIX correctness in ~/.bash_profile (diff) | |
download | dotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.tar.gz dotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.zip |
Apply runtime shebanging to POSIX shell
Diffstat (limited to 'bin/dmp.sh')
-rw-r--r-- | bin/dmp.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/dmp.sh b/bin/dmp.sh new file mode 100644 index 00000000..ea79214f --- /dev/null +++ b/bin/dmp.sh @@ -0,0 +1,30 @@ + +# Get the password store directory, bail if we can't +pwsd=${PASSWORD_STORE_DIR:-"$HOME"/.password-store} +pwsd=${pwsd%/} +[ -n "$pwsd" ] || exit + +# Get the password; get all the names from find(1) +# shellcheck disable=SC2016 +pw=$( + cd -- "$pwsd" || exit + # Get all the names from find(1) + find ./ -name \*.gpg | + # Sort them + sort | + # Strip the leading directory and the trailing .gpg + sed 's_^\./__;s_\.gpg$__' | + # Use dmenu(1) to prompt the user to select one + dmenu +) || exit + +# Bail if we don't have a password +[ -n "$pw" ] || exit + +# Pump the first line of the password into the clipboard +pass show "$pw" | sed 1q | xsel -ib || exit + +# If we have notify-send(1), alert that the password has been copied +if command -v notify-send >/dev/null >&2 ; then + notify-send "$(printf '%s in clipboard' "$pw")" +fi |