aboutsummaryrefslogtreecommitdiff
path: root/passmenu-otp
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-02-17 16:20:40 +0100
committerLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-02-17 16:20:40 +0100
commitc74163f1ecbd809c83bb465ee89fa04369a89972 (patch)
treec1a52692a47566652d7f2a9a8eceb9f1839991b7 /passmenu-otp
parent70e6d80c2d367480478eacf46363ee88a0e994ff (diff)
downloadbin-c74163f1ecbd809c83bb465ee89fa04369a89972.tar.gz
bin-c74163f1ecbd809c83bb465ee89fa04369a89972.zip
cleaned up names and dir
Diffstat (limited to 'passmenu-otp')
-rwxr-xr-xpassmenu-otp24
1 files changed, 14 insertions, 10 deletions
diff --git a/passmenu-otp b/passmenu-otp
index d511944..11a236b 100755
--- a/passmenu-otp
+++ b/passmenu-otp
@@ -1,24 +1,28 @@
#!/bin/sh
set -eu
+# Config
: "${PASSWORD_STORE_DIR:=$HOME/.password-store}"
DMENU="${DMENU:-dmenu}"
+OTP_PREFIX="${OTP_PREFIX:-otp}" # expects entries under $PASSWORD_STORE_DIR/otp/
-# Build list of pass entry paths (relative to PASSWORD_STORE_DIR) that contain an otpauth:// line.
+otp_dir="$PASSWORD_STORE_DIR/$OTP_PREFIX"
+
+# If no otp/ subtree exists, exit quietly
+[ -d "$otp_dir" ] || exit 0
+
+# Build list of entry names from filenames only (no decryption).
entries=$(
- find "$PASSWORD_STORE_DIR" -type f -name '*.gpg' ! -path '*/.git/*' -print 2>/dev/null |
- while IFS= read -r f; do
- entry="${f#$PASSWORD_STORE_DIR/}"
- entry="${entry%.gpg}"
- if pass show "$entry" 2>/dev/null | grep -q '^otpauth://'; then
- printf '%s\n' "$entry"
- fi
- done
+ find "$otp_dir" -type f -name '*.gpg' ! -path '*/.git/*' -print 2>/dev/null |
+ sed -e "s|^$PASSWORD_STORE_DIR/||" -e 's|\.gpg$||' |
+ sort
)
[ -n "${entries:-}" ] || exit 0
-choice=$(printf '%s\n' "$entries" | "$DMENU" -i -p "OTP:")
+choice=$(printf '%s\n' "$entries" | $DMENU -i -p "OTP:")
[ -n "${choice:-}" ] || exit 0
+# Copy OTP to clipboard using pass-otp extension (-c handles clipboard + clearing).
pass otp -c "$choice"
+