2020-06-27 04:24:22 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Credit goes to https://git.reekynet.com/ReekyMarko/fzf-pass for this.
|
|
|
|
|
|
|
|
cd "$HOME/.password-store" || exit 1
|
|
|
|
PASSFILE=$(tree -Ffi \
|
|
|
|
| grep '.gpg' \
|
|
|
|
| sed 's/.gpg$//g' \
|
|
|
|
| sed 's/^..//' \
|
2020-08-18 03:35:39 +00:00
|
|
|
| fzf \
|
|
|
|
--color="gutter:0,prompt:2" \
|
|
|
|
--no-info \
|
|
|
|
--no-multi \
|
|
|
|
--pointer='➜' \
|
|
|
|
--preview "echo {} && (echo {} | sed 's/./-/g') && pass {}" \
|
|
|
|
--prompt='pass::' \
|
|
|
|
--reverse )
|
2020-06-27 04:24:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$PASSFILE" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
RESP=$(cat <<EOF | fzf
|
|
|
|
Autotype
|
|
|
|
Username
|
|
|
|
Password
|
|
|
|
Page
|
2020-08-16 21:40:27 +00:00
|
|
|
QR
|
2020-06-27 04:24:22 +00:00
|
|
|
EOF
|
|
|
|
);
|
|
|
|
|
|
|
|
case "$RESP" in
|
2020-08-18 03:35:16 +00:00
|
|
|
Autotype)
|
2020-08-16 21:40:08 +00:00
|
|
|
swaymsg exec "source ~/.profile \
|
|
|
|
&& ydotool type \"\$(pass get_user $PASSFILE)\" \
|
|
|
|
&& ydotool key TAB \
|
|
|
|
&& ydotool type \"\$(pass get_pass $PASSFILE)\""
|
2020-08-18 03:35:16 +00:00
|
|
|
;;
|
|
|
|
Username)
|
2020-08-16 21:40:08 +00:00
|
|
|
swaymsg exec "source ~/.profile \
|
|
|
|
&& ydotool type \"\$(pass get_user $PASSFILE)\""
|
2020-08-18 03:35:16 +00:00
|
|
|
;;
|
|
|
|
Password)
|
2020-08-16 21:40:08 +00:00
|
|
|
swaymsg exec "source ~/.profile \
|
|
|
|
&& ydotool type \"\$(pass get_pass $PASSFILE)\""
|
2020-08-18 03:35:16 +00:00
|
|
|
;;
|
|
|
|
Page)
|
2020-08-16 21:03:44 +00:00
|
|
|
pass "$PASSFILE" | LESS=R less
|
2020-08-18 03:35:16 +00:00
|
|
|
;;
|
2020-08-16 21:40:27 +00:00
|
|
|
QR)
|
|
|
|
swaymsg exec "pass show \"${PASSFILE}\" --qrcode"
|
|
|
|
;;
|
2020-08-18 03:35:16 +00:00
|
|
|
*)
|
|
|
|
exit 1
|
2020-06-27 04:24:22 +00:00
|
|
|
esac
|