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}" )
|
2023-05-03 07:54:29 +02:00
|
|
|
password=$(printf '%s\n' "${password_files[@]}" \
|
2023-05-12 17:24:59 +02:00
|
|
|
| fzf -e -i $EXTRA --preview="gpg -d ${prefix}/{1}.gpg \
|
2023-05-03 07:54:29 +02:00
|
|
|
2> /dev/null ")
|
2023-04-26 12:31:59 +02:00
|
|
|
|
|
|
|
[[ -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 "---------"
|
2023-05-12 17:24:59 +02:00
|
|
|
echo -n "[E]dit | [R]ename | [N]ew Password | [D]elete: "
|
2023-04-26 12:31:59 +02:00
|
|
|
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-05-12 17:24:59 +02:00
|
|
|
[nN]) pass generate -i "$password" 22; ;;
|
2023-04-26 12:31:59 +02:00
|
|
|
[dD]) pass rm "$password"; unset EXTRA; ;;
|
|
|
|
esac
|
2023-11-27 09:02:44 +01:00
|
|
|
echo "Updating ksh completions"
|
|
|
|
ksh-update-completions
|
2023-04-26 12:31:59 +02:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Press any key to continue"
|
|
|
|
read
|
|
|
|
|
2023-02-22 08:31:38 +01:00
|
|
|
done
|