dotfiles/sway/scripts/fzf-pass
James Patrick 7999a4110e Moving fzf-pass local versioning.
I'm loosing the versioning but I think I'm going to take this in a
different direction.

1. work with standard browser pass format. Including with pass or as
leading line.
2. Be fully system agnostic (ydotool, of clipboard stuff can be added on
top)
3. Have option to print current full text.

All of these will require significant changes.
2020-06-27 00:30:05 -04:00

51 lines
974 B
Bash
Executable File

#!/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/^..//' \
| fzf --reverse --no-info --prompt='pass::' --pointer='➜' --no-multi )
if [ -z "$PASSFILE" ]; then
exit 0
fi
PASSDATA="$(pass "$PASSFILE")"
USRNAME="$(echo "$PASSDATA" | grep "username:" | cut -d' ' -f2-)"
PASS="$(echo "$PASSDATA" | head -n 1)"
URL="$(echo "$PASSDATA" | grep url: | cut -d' ' -f2-)"
RESP=$(cat <<EOF | fzf
Autotype
Username
Password
URL
Page
EOF
);
swaymsg move container to workspace 9
case "$RESP" in
Autotype)
ydotool type "$USRNAME" && ydotool key Tab && ydotool type "$PASS" && ydotool key Enter
;;
Username)
ydotool type "$USRNAME"
;;
Password)
ydotool type "$PASS"
;;
URL)
ydotool type "$URL"
;;
Page)
"$(dirname "$0")/tty-popup" info "bash -c 'echo ${PASSDATA} | LESS=R less'"
;;
*)
exit 1
esac