summaryrefslogtreecommitdiff
path: root/bin/P
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2015-10-07 21:53:35 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2015-10-07 21:53:35 -0400
commitc2ed84f6632a9c3521242ad7e2d8ae4e1e8c5770 (patch)
tree2634a535fda30d4a654b9e8128b87ff0233298b4 /bin/P
parent9ae9f06d2012167fcc6f91f2f28f98eced01365a (diff)
parent820bd83a3d969c6ec2e48d0421e41cffcc7c0c95 (diff)
Merge branch 'master' of tesuji.6.orbekk.com:/storage/projects/dotfiles
Diffstat (limited to 'bin/P')
-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