Archived
1
0
Fork 0
This repository has been archived on 2024-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/simpleDots/bin/fzpass

29 lines
923 B
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
)
## Send the filelist to fzf, use # for a preview and
## disable the fzf mous to use the primary selection
password=$( printf '%s\n' "${password_files[@]}" \
| fzf --bind='#:toggle-preview' \
2022-02-22 10:55:54 +01:00
--preview='pass show {}' \
--preview-window="hidden" \
--no-mouse \
$@ \
2022-02-18 22:48:34 +01:00
)
## Exit if nothing was selected
test "_$password" = "_" && exit
pass show -c "$password" 2>/dev/null