2023-02-22 08:31:38 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
shopt -s nullglob globstar
|
|
|
|
|
|
|
|
prefix=${PASSWORD_STORE_DIR-~/.password-store}
|
|
|
|
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
|
2023-04-26 15:39:28 +02:00
|
|
|
unset password_files
|
|
|
|
unset PASS
|
|
|
|
unset FOLDER
|
2023-04-26 12:31:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
password_files=( "$prefix"/**/*.gpg )
|
|
|
|
password_files=( "${password_files[@]#"$prefix"/}" )
|
|
|
|
password_files=( "${password_files[@]%.gpg}" )
|
|
|
|
password=$(printf '%s\n' "${password_files[@]}" | fzf -i $EXTRA --preview="pass {1}")
|
|
|
|
|
|
|
|
[[ -n "$password" ]] || exit
|
|
|
|
|
|
|
|
EXTRA="-q ${password#*/}"
|
|
|
|
|
2023-04-26 15:39:28 +02:00
|
|
|
echo "$password" | fgrep -q '/' && FOLDER="${password%/*}/"
|
|
|
|
|
2023-04-26 12:31:59 +02:00
|
|
|
echo "---------"
|
|
|
|
echo "Selected: $password"
|
|
|
|
PASS="$(pass "$password")"
|
|
|
|
echo "Password: $(echo "$PASS" | head -1)"
|
|
|
|
echo "$PASS" | grep -i "^username:"
|
|
|
|
echo "$PASS" | grep -i "^email:"
|
|
|
|
echo "$PASS" | grep -i "^url:"
|
|
|
|
echo "---------"
|
|
|
|
echo -n "[E]dit [R]ename [N]ew [D]elete: "
|
|
|
|
read
|
|
|
|
|
|
|
|
case $REPLY in
|
|
|
|
[eE]) echo "Editing $password."; pass edit "$password"; ;;
|
2023-04-26 15:39:28 +02:00
|
|
|
[rR]) echo -n "Rename to: "; read -i "$FOLDER" -e REPLY; [ ! -z "$REPLY" ] && pass mv "$password" "$REPLY"; ;;
|
2023-04-26 12:31:59 +02:00
|
|
|
[nN]) pass generate -i "$password" 22; ;;
|
|
|
|
[dD]) pass rm "$password"; unset EXTRA; ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Press any key to continue"
|
|
|
|
read
|
|
|
|
|
2023-02-22 08:31:38 +01:00
|
|
|
done
|