blob: d511944e440a597941fc26c2b6b3cef2406e3560 (
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
|
#!/bin/sh
set -eu
: "${PASSWORD_STORE_DIR:=$HOME/.password-store}"
DMENU="${DMENU:-dmenu}"
# Build list of pass entry paths (relative to PASSWORD_STORE_DIR) that contain an otpauth:// line.
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
)
[ -n "${entries:-}" ] || exit 0
choice=$(printf '%s\n' "$entries" | "$DMENU" -i -p "OTP:")
[ -n "${choice:-}" ] || exit 0
pass otp -c "$choice"
|