helm/shell/+fzf/bin/fzf-pass

29 lines
809 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
shopt -s nullglob globstar
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
2017-04-25 11:19:21 -07:00
# entry=$(printf "%s\n" "${password_files[@]}" | rofi -dmenu -p pass: "$@")
entry=$(printf "%s\n" "${password_files[@]}" | gui-fzf)
[[ -n $entry ]] || exit
out=$(pass show "$entry")
[[ $out ]] || exit
fields=$(echo "$out" | cut -d: -f1 | tail -n +2)
2017-04-25 11:19:21 -07:00
# field=$(printf "password\n%s\n" "${fields[@]}" | rofi -dmenu -p pass:field:)
field=$(printf "password\n%s\n" "${fields[@]}" | gui-fzf)
case "$field" in
password)
pass -c "$entry"
;;
*)
echo "$out" | grep "^${field}:" | awk '{print $2}' | xclip -selection clipboard -in
;;
esac