From c74163f1ecbd809c83bb465ee89fa04369a89972 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 17 Feb 2026 16:20:40 +0100 Subject: cleaned up names and dir --- passmenu-otp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'passmenu-otp') 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" + -- cgit v1.3