1
0
Fork 0

fzpass: Add linewrapping in preview

This commit is contained in:
J. Elfring 2024-11-02 20:03:59 +01:00
parent 1de4b0a771
commit 29ca84ab0c

View file

@ -6,44 +6,44 @@ prefix=${PASSWORD_STORE_DIR:=~/.password-store}
## Get all the gpg files in all directories and subdirs... ## Get all the gpg files in all directories and subdirs...
## remove the prefix, some 3 extra chars and the .gpg ending ## remove the prefix, some 3 extra chars and the .gpg ending
password_files=$( find $prefix -name '*.gpg' \ password_files=$(
| cut --characters ${#prefix}- \ find $prefix -name '*.gpg' |
| cut --characters 3- \ cut --characters ${#prefix}- |
| rev | cut --characters 5- | rev cut --characters 3- |
) rev | cut --characters 5- | rev
)
## Some functions to call from inside the fzf menu ## Some functions to call from inside the fzf menu
fzpass_update () { fzpass_update() {
echo "--Pulling..." 2>&1 >/dev/tty echo "--Pulling..." 2>&1 >/dev/tty
pass git pull 2>&1 >/dev/tty pass git pull 2>&1 >/dev/tty
echo "--Pushing..." 2>&1 >/dev/tty echo "--Pushing..." 2>&1 >/dev/tty
pass git push 2>&1 >/dev/tty pass git push 2>&1 >/dev/tty
echo "--Any key to continue..." 2>&1 >/dev/tty echo "--Any key to continue..." 2>&1 >/dev/tty
read read
} }
export -f fzpass_update export -f fzpass_update
## Send the filelist to fzf, ## Send the filelist to fzf,
## disable the fzf mouse to use the primary selection ## disable the fzf mouse to use the primary selection
password=$( printf '%s\n' "${password_files[@]}" \ password=$(
| fzf --bind='ctrl-s:toggle-preview' \ printf '%s\n' "${password_files[@]}" |
--bind='ctrl-u:execute(fzpass_update)' \ fzf --bind='ctrl-s:toggle-preview' \
--bind='ctrl-r:execute(pass rm {})' \ --bind='ctrl-u:execute(fzpass_update)' \
--bind='ctrl-e:execute(pass edit {} < /dev/tty > /dev/tty)' \ --bind='ctrl-r:execute(pass rm {})' \
--preview='pass show {}' \ --bind='ctrl-e:execute(pass edit {} < /dev/tty > /dev/tty)' \
--preview-window="hidden" \ --preview='pass show {}' \
--no-mouse \ --preview-window="up,30%,hidden,wrap" \
--header=' --no-mouse \
--header='
Ret: Copy pass, show OTP; C-s: Show entry; C-e: Edit entry Ret: Copy pass, show OTP; C-s: Show entry; C-e: Edit entry
C-u: Update (pull, push); C-r: Remove' C-u: Update (pull, push); C-r: Remove'
$@ \ $@
) )
## Exit if nothing was selected ## Exit if nothing was selected
test "_$password" = "_" && exit test "_$password" = "_" && exit
## Copy pass and show otp, exit silently if anything fails ## Copy pass and show otp, exit silently if anything fails
pass show -c "$password" pass show -c "$password"
pass otp "$password" 2>/dev/null || exit 0 pass otp "$password" 2>/dev/null || exit 0