Extend fzpass
This commit is contained in:
parent
96eb100e67
commit
f3dd5b13f8
1 changed files with 21 additions and 7 deletions
|
@ -3,7 +3,6 @@
|
|||
## 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
|
||||
|
@ -13,23 +12,38 @@ password_files=$( find $prefix -name '*.gpg' \
|
|||
| rev | cut --characters 5- | rev
|
||||
)
|
||||
|
||||
## Some functions to call from inside the fzf menu
|
||||
fzpass_update () {
|
||||
echo "--Pulling..." 2>&1 >/dev/tty
|
||||
pass git pull 2>&1 >/dev/tty
|
||||
echo "--Pushing..." 2>&1 >/dev/tty
|
||||
pass git push 2>&1 >/dev/tty
|
||||
echo "--Any key to continue..." 2>&1 >/dev/tty
|
||||
read
|
||||
}
|
||||
export -f fzpass_update
|
||||
|
||||
|
||||
## Send the filelist to fzf,
|
||||
## disable the fzf mouse to use the primary selection
|
||||
password=$( printf '%s\n' "${password_files[@]}" \
|
||||
| fzf --bind='ctrl-s:toggle-preview' \
|
||||
--bind='ctrl-u:execute(pass git pull)+execute(pass git push)' \
|
||||
--bind='ctrl-u:execute(fzpass_update)' \
|
||||
--bind='ctrl-delete:execute(pass rm {})' \
|
||||
--bind='ctrl-e:execute(pass edit {} < /dev/tty > /dev/tty)' \
|
||||
--preview='pass show {}' \
|
||||
--preview-window="hidden" \
|
||||
--no-mouse \
|
||||
--header='
|
||||
Ret: Copy password & show OTP; C-s: Show entry; C-e: Edit entry
|
||||
C-u: Update repo (Pull & Push)'
|
||||
Ret: Copy pass, show OTP; C-s: Show entry; C-e: Edit entry
|
||||
C-u: Update (pull, push); C-DEL: Delete'
|
||||
$@ \
|
||||
)
|
||||
|
||||
## Exit if nothing was selected
|
||||
test "_$password" = "_" && exit
|
||||
|
||||
pass show -c "$password" 2>/dev/null
|
||||
pass otp "$password" 2>/dev/null
|
||||
## Copy pass and show otp, exit silently if anything fails
|
||||
pass show -c "$password" 2>/dev/null || exit 0
|
||||
pass otp "$password" 2>/dev/null || exit 0
|
||||
|
||||
|
|
Reference in a new issue