1
0
mirror of https://github.com/octoleo/Purse.git synced 2024-12-28 20:12:38 +00:00

Indent by 2 spaces throughout. Add example for copying password to clipboard on OS X.

This commit is contained in:
drduh 2015-07-31 00:53:28 -04:00
parent 62ce715108
commit 866bbff0eb
2 changed files with 13 additions and 9 deletions

View File

@ -28,6 +28,10 @@ Options can also be passed on the command line, e.g.,
`./pwd.sh d dropbox` to delete the password called 'dropbox'.
Combine with other programs by piping output, e.g.,
`./pwd.sh r github | grep github | cut -f1 -d ' ' | pbcopy` to copy a password to clipboard on OS X.
The script and `pwd.sh.safe` encrypted file can be safely shared between machines over public channels (Google Drive, Dropbox, etc).
A sample `gpg.conf` configuration file is provided for your consideration.

18
pwd.sh
View File

@ -23,6 +23,7 @@ get_pass () {
password=''
prompt="${1}"
while IFS= read -p "${prompt}" -r -s -n 1 char ; do
if [[ ${char} == $'\0' ]] ; then
break
@ -57,7 +58,6 @@ decrypt () {
encrypt () {
# Encrypt with a password.
${gpg} \
--symmetric --armor --batch --yes \
--passphrase-fd 3 \
@ -145,17 +145,17 @@ create_username () {
# Create a new username and password.
if [[ -z "${2+x}" ]] ; then
read -p "
read -p "
Username: " username
else
username="${2}"
username="${2}"
fi
if [[ -z "${3+x}" ]] ; then
read -p "
read -p "
Generate password? (y/n, default: y) " rand_pass
else
rand_pass=""
rand_pass=""
fi
if [[ "${rand_pass}" =~ ^([nN][oO]|[nN])$ ]]; then
@ -182,11 +182,11 @@ sanity_check () {
sanity_check
if [[ -z "${1+x}" ]] ; then
read -n 1 -p "
read -n 1 -p "
Read, write, or delete password? (r/w/d, default: r) " action
printf "\n"
printf "\n"
else
action="${1}"
action="${1}"
fi
if [[ "${action}" =~ ^([wW])$ ]] ; then
@ -198,7 +198,7 @@ elif [[ "${action}" =~ ^([dD])$ ]] ; then
read -p "
Username to delete? " username
else
username="${2}"
username="${2}"
fi
write_pass