blob: 11a236b7844bbc01473421d0621419ea51456246 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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/
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 "$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:")
[ -n "${choice:-}" ] || exit 0
# Copy OTP to clipboard using pass-otp extension (-c handles clipboard + clearing).
pass otp -c "$choice"
|