summaryrefslogtreecommitdiff
path: root/rofi-pass.sh
diff options
context:
space:
mode:
Diffstat (limited to 'rofi-pass.sh')
-rwxr-xr-xrofi-pass.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/rofi-pass.sh b/rofi-pass.sh
new file mode 100755
index 0000000..1366466
--- /dev/null
+++ b/rofi-pass.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+prefix=${PASSWORD_STORE_DIR:-~/.password-store}
+
+get_passwords() {
+ find -s "$prefix" -type f -name '*.gpg'
+}
+
+trim_prefix() {
+ while read line
+ do
+ printf '%s\n' "${line##$prefix/}"
+ done
+}
+
+trim_gpg() {
+ while read line
+ do
+ printf '%s\n' "${line%%.gpg}"
+ done
+}
+
+[ -z "$2" ] && get_passwords | trim_prefix | trim_gpg && exit 0
+
+case "$1" in
+ otp*)
+ pass otp --clip "${2##totp:}" >/dev/null 2>&1 &
+ ;;
+ pass*)
+ pass show --clip "${2##password:}" >/dev/null 2>&1 &
+ ;;
+esac