mirror of
https://github.com/octoleo/Purse.git
synced 2024-12-29 12:32:39 +00:00
Add newlines for improved readability.
This commit is contained in:
parent
8553d6802a
commit
576fb78ac2
41
pwd.sh
41
pwd.sh
@ -72,10 +72,12 @@ read_pass () {
|
|||||||
username=""
|
username=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -s ${safe} ] ; then
|
if [[ ! -s ${safe} ]] ; then
|
||||||
fail "No passwords found"
|
fail "No passwords found"
|
||||||
else
|
else
|
||||||
get_pass "Enter password to unlock ${safe}: " ; echo
|
get_pass "
|
||||||
|
Enter password to unlock ${safe}: "
|
||||||
|
printf "\n\n"
|
||||||
decrypt ${password} ${safe} | grep " ${username}" || fail "Decryption failed"
|
decrypt ${password} ${safe} | grep " ${username}" || fail "Decryption failed"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -84,9 +86,10 @@ read_pass () {
|
|||||||
gen_pass () {
|
gen_pass () {
|
||||||
# Generate a password.
|
# Generate a password.
|
||||||
|
|
||||||
len=40
|
len=50
|
||||||
max=100
|
max=100
|
||||||
read -p "Password length? (default: ${len}, max: ${max}) " length
|
read -p "
|
||||||
|
Password length? (default: ${len}, max: ${max}) " length
|
||||||
|
|
||||||
if [[ ${length} =~ ^[0-9]+$ ]] ; then
|
if [[ ${length} =~ ^[0-9]+$ ]] ; then
|
||||||
len=${length}
|
len=${length}
|
||||||
@ -107,7 +110,8 @@ write_pass () {
|
|||||||
new_entry="${userpass} ${username}"
|
new_entry="${userpass} ${username}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_pass "Enter password to unlock ${safe}: " ; echo
|
get_pass "
|
||||||
|
Enter password to unlock ${safe}: " ; echo
|
||||||
|
|
||||||
# If safe exists, decrypt it and filter out username, or bail on error.
|
# If safe exists, decrypt it and filter out username, or bail on error.
|
||||||
# If successful, append new entry, or blank line.
|
# If successful, append new entry, or blank line.
|
||||||
@ -128,14 +132,19 @@ write_pass () {
|
|||||||
create_username () {
|
create_username () {
|
||||||
# Create a new username and password.
|
# Create a new username and password.
|
||||||
|
|
||||||
read -p "Username: " username
|
read -p "
|
||||||
read -p "Generate password? (y/n, default: y) " rand_pass
|
Username: " username
|
||||||
|
read -p "
|
||||||
|
Generate password? (y/n, default: y) " rand_pass
|
||||||
|
|
||||||
if [ "${rand_pass}" == "n" ]; then
|
if [ "${rand_pass}" == "n" ]; then
|
||||||
get_pass "Enter password for \"${username}\": " ; echo
|
get_pass "
|
||||||
|
Enter password for \"${username}\": " ; echo
|
||||||
userpass=$password
|
userpass=$password
|
||||||
else
|
else
|
||||||
userpass=$(gen_pass)
|
userpass=$(gen_pass)
|
||||||
echo "Password: ${userpass}"
|
echo "
|
||||||
|
Password: ${userpass}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,17 +160,19 @@ sanity_check () {
|
|||||||
|
|
||||||
sanity_check
|
sanity_check
|
||||||
|
|
||||||
read -p "Read, write, or delete a password? (r/w/d, default: r) " action
|
read -n 1 -p "Read, write, or delete password? (r/w/d, default: r) " action
|
||||||
|
printf "\n"
|
||||||
|
|
||||||
if [ "${action}" == "w" ] ; then
|
if [ "${action}" == "w" ] ; then
|
||||||
create_username && write_pass
|
create_username && write_pass
|
||||||
elif [ "${action}" == "d" ] ; then
|
elif [ "${action}" == "d" ] ; then
|
||||||
read -p "Username to delete? " username
|
read -p "
|
||||||
write_pass
|
Username to delete? " username && write_pass
|
||||||
else
|
else
|
||||||
read -p "Username to read? (default: all) " username
|
read -p "
|
||||||
read_pass
|
Username to read? (default: all) " username && read_pass
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tput setaf 2 ; echo "Done" ; tput sgr0
|
tput setaf 2 ; echo "
|
||||||
|
Done" ; tput sgr0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user