1
0
Fork 0
dotfiles/simpleDots/bin/fzpass

36 lines
1.2 KiB
Text
Raw Normal View History

2022-02-18 22:48:34 +01:00
#!/bin/bash
## A wrapper for pass to use fzf to find passwords.
prefix=${PASSWORD_STORE_DIR:=~/.password-store}
prefixlength=${#prefix}
## Get all the gpg files in all directories and subdirs...
## remove the prefix, some 3 extra chars and the .gpg ending
password_files=$( find $prefix -name '*.gpg' \
| cut --characters ${#prefix}- \
| cut --characters 3- \
2022-04-23 20:54:44 +02:00
| rev | cut --characters 5- | rev
2022-02-18 22:48:34 +01:00
)
2023-05-22 14:37:59 +02:00
## Send the filelist to fzf,
## disable the fzf mouse to use the primary selection
2022-02-18 22:48:34 +01:00
password=$( printf '%s\n' "${password_files[@]}" \
2023-05-22 14:37:59 +02:00
| fzf --bind='ctrl-s:toggle-preview' \
--bind='ctrl-u:execute(pass git pull)+execute(pass git push)' \
--bind='ctrl-e:execute(pass edit {} < /dev/tty > /dev/tty)' \
2022-02-22 10:55:54 +01:00
--preview='pass show {}' \
--preview-window="hidden" \
--no-mouse \
2023-05-22 14:37:59 +02:00
--header='
Ret: Copy password & show OTP; C-s: Show entry; C-e: Edit entry
C-u: Update repo (Pull & Push)'
2022-02-22 10:55:54 +01:00
$@ \
2022-02-18 22:48:34 +01:00
)
## Exit if nothing was selected
test "_$password" = "_" && exit
pass show -c "$password" 2>/dev/null
2023-05-22 14:37:59 +02:00
pass otp "$password" 2>/dev/null