summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2015-10-01 20:04:01 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2015-10-01 20:04:01 -0400
commit525538bdd58640442d6d7c4f2e9335fa140b9dde (patch)
tree534dbef30d69959ccfeee112b9fb9517cab9156a /bin
parent4b1e510f75093b7da5b85f6f83d19f525df98b6e (diff)
Add P shortcut to password manager dmenu.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/P24
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/P b/bin/P
new file mode 100755
index 0000000..492d3d8
--- /dev/null
+++ b/bin/P
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+shopt -s nullglob globstar
+
+typeit=0
+if [[ $1 == "--type" ]]; then
+ typeit=1
+ shift
+fi
+
+prefix=${PASSWORD_STORE_DIR-~/.password-store}
+password_files=( "$prefix"/**/*.gpg )
+password_files=( "${password_files[@]#"$prefix"/}" )
+password_files=( "${password_files[@]%.gpg}" )
+
+password=$(printf '%s\n' "${password_files[@]}" | dmenu -fn "-*-*-*-*-*-*-20-*-*-*-*-*-*-*" "$@")
+
+[[ -n $password ]] || exit
+
+if [[ $typeit -eq 0 ]]; then
+ pass show -c "$password" 2>/dev/null
+else
+ xdotool - <<<"type --clearmodifiers -- $(pass show "$password" | head -n 1)"
+fi