shell/fzf/bin/fzf-pass: add pass-otp support

This commit is contained in:
Henrik Lissner 2017-12-23 19:55:09 -05:00
parent 4fb5501fd2
commit d723cec77b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -36,13 +36,12 @@ echo "$entry" >/tmp/_upm
secrets="$(pass show "$entry")" secrets="$(pass show "$entry")"
if [[ $secrets ]]; then if [[ $secrets ]]; then
fields=$(awk -F': ' 'NR>1 && !/^otpauth:/ {print $1}' <<<"$secrets") fields=$(awk -F': ' 'NR>1 && !/^otpauth:/ {print $1}' <<<"$secrets")
field=$(printf "password\n%s\n" "${fields[@]}" | fzf --prompt="pass ($entry) > ") field=$(printf "password\n%s\notp\n" "${fields[@]}" | fzf --prompt="pass ($entry) > ")
case $field in
if [[ $field == password ]]; then password) printf "%s" "$(head -n1 <<<"$secrets")" ;;
printf "%s" "$(head -n1 <<<"$secrets")" otp) printf "%s" "$(pass otp "$entry")" ;;
else *) printf "%s" "$(awk -v "key=$field:" '$1 == key {print $2}' <<<"$secrets")" ;;
printf "%s" "$(awk -v "key=$field:" '$1 == key {print $2}' <<<"$secrets")" esac | xsel -i -b -t 15000
fi | xsel -i -b -t 15000
notify-send --urgency=low "<b>$entry -> $field</b>" "Copied to clipboard for 15s" notify-send --urgency=low "<b>$entry -> $field</b>" "Copied to clipboard for 15s"
else else
notify-send --urgency=critical "Failed to retrieve $entry" notify-send --urgency=critical "Failed to retrieve $entry"