From d723cec77b93c1538b5baf8ea8e77e0853636f23 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 23 Dec 2017 19:55:09 -0500 Subject: [PATCH] shell/fzf/bin/fzf-pass: add pass-otp support --- shell/fzf/bin/fzf-pass | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/shell/fzf/bin/fzf-pass b/shell/fzf/bin/fzf-pass index f2f77550..938754fb 100755 --- a/shell/fzf/bin/fzf-pass +++ b/shell/fzf/bin/fzf-pass @@ -36,13 +36,12 @@ echo "$entry" >/tmp/_upm secrets="$(pass show "$entry")" if [[ $secrets ]]; then fields=$(awk -F': ' 'NR>1 && !/^otpauth:/ {print $1}' <<<"$secrets") - field=$(printf "password\n%s\n" "${fields[@]}" | fzf --prompt="pass ($entry) > ") - - if [[ $field == password ]]; then - printf "%s" "$(head -n1 <<<"$secrets")" - else - printf "%s" "$(awk -v "key=$field:" '$1 == key {print $2}' <<<"$secrets")" - fi | xsel -i -b -t 15000 + field=$(printf "password\n%s\notp\n" "${fields[@]}" | fzf --prompt="pass ($entry) > ") + case $field in + password) printf "%s" "$(head -n1 <<<"$secrets")" ;; + otp) printf "%s" "$(pass otp "$entry")" ;; + *) printf "%s" "$(awk -v "key=$field:" '$1 == key {print $2}' <<<"$secrets")" ;; + esac | xsel -i -b -t 15000 notify-send --urgency=low "$entry -> $field" "Copied to clipboard for 15s" else notify-send --urgency=critical "Failed to retrieve $entry"