wpass: allow copying arbitrary keys

This commit is contained in:
Leonardo Eugênio 2026-03-03 23:26:25 -03:00
parent eb5e752b44
commit b5690aaaee

View file

@ -18,6 +18,13 @@ print_actions_for_entry() {
if test -n "$otp"; then if test -n "$otp"; then
echo "OTP" echo "OTP"
fi fi
echo "$entry_content" | \
rg '^(\w+): .*$' --replace '$1' | \
sed \
-e '/login/d' \
-e '/user/d' \
-e '/email/d'
} }
main() { main() {
@ -29,8 +36,9 @@ main() {
test -n "$entry" || exit 0 test -n "$entry" || exit 0
username=`pass show "$entry" 2>/dev/null | rg -m1 '(login|user|email): (.*)' -r '$2'` || true entry_content="$(pass show "$entry" 2>/dev/null)" || true
password=`pass show "$entry" 2>/dev/null | head -n 1` || true username=`echo "$entry_content" | rg -m1 '(login|user|email): (.*)' -r '$2'` || true
password=`echo "$entry_content" | head -n 1` || true
otp=`pass otp "$entry" 2>/dev/null` || true otp=`pass otp "$entry" 2>/dev/null` || true
action="$(print_actions_for_entry | wdmenu -p Action)" action="$(print_actions_for_entry | wdmenu -p Action)"
@ -45,6 +53,10 @@ main() {
printf '%s' "$password" | wl-copy;; printf '%s' "$password" | wl-copy;;
OTP) OTP)
pass otp "$entry" | wl-copy;; pass otp "$entry" | wl-copy;;
*)
key="$action"
printf '%s\n' "$entry_content" | rg -m1 "^$key: (.*)" -r '$1' | wl-copy -n
;;
esac esac
} }