mirror of https://github.com/octoleo/Purse.git
Indent by 2 spaces throughout. Add example for copying password to clipboard on OS X.
This commit is contained in:
parent
62ce715108
commit
866bbff0eb
|
@ -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'.
|
`./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).
|
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.
|
A sample `gpg.conf` configuration file is provided for your consideration.
|
||||||
|
|
18
pwd.sh
18
pwd.sh
|
@ -23,6 +23,7 @@ get_pass () {
|
||||||
|
|
||||||
password=''
|
password=''
|
||||||
prompt="${1}"
|
prompt="${1}"
|
||||||
|
|
||||||
while IFS= read -p "${prompt}" -r -s -n 1 char ; do
|
while IFS= read -p "${prompt}" -r -s -n 1 char ; do
|
||||||
if [[ ${char} == $'\0' ]] ; then
|
if [[ ${char} == $'\0' ]] ; then
|
||||||
break
|
break
|
||||||
|
@ -57,7 +58,6 @@ decrypt () {
|
||||||
encrypt () {
|
encrypt () {
|
||||||
# Encrypt with a password.
|
# Encrypt with a password.
|
||||||
|
|
||||||
|
|
||||||
${gpg} \
|
${gpg} \
|
||||||
--symmetric --armor --batch --yes \
|
--symmetric --armor --batch --yes \
|
||||||
--passphrase-fd 3 \
|
--passphrase-fd 3 \
|
||||||
|
@ -145,17 +145,17 @@ create_username () {
|
||||||
# Create a new username and password.
|
# Create a new username and password.
|
||||||
|
|
||||||
if [[ -z "${2+x}" ]] ; then
|
if [[ -z "${2+x}" ]] ; then
|
||||||
read -p "
|
read -p "
|
||||||
Username: " username
|
Username: " username
|
||||||
else
|
else
|
||||||
username="${2}"
|
username="${2}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${3+x}" ]] ; then
|
if [[ -z "${3+x}" ]] ; then
|
||||||
read -p "
|
read -p "
|
||||||
Generate password? (y/n, default: y) " rand_pass
|
Generate password? (y/n, default: y) " rand_pass
|
||||||
else
|
else
|
||||||
rand_pass=""
|
rand_pass=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${rand_pass}" =~ ^([nN][oO]|[nN])$ ]]; then
|
if [[ "${rand_pass}" =~ ^([nN][oO]|[nN])$ ]]; then
|
||||||
|
@ -182,11 +182,11 @@ sanity_check () {
|
||||||
sanity_check
|
sanity_check
|
||||||
|
|
||||||
if [[ -z "${1+x}" ]] ; then
|
if [[ -z "${1+x}" ]] ; then
|
||||||
read -n 1 -p "
|
read -n 1 -p "
|
||||||
Read, write, or delete password? (r/w/d, default: r) " action
|
Read, write, or delete password? (r/w/d, default: r) " action
|
||||||
printf "\n"
|
printf "\n"
|
||||||
else
|
else
|
||||||
action="${1}"
|
action="${1}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${action}" =~ ^([wW])$ ]] ; then
|
if [[ "${action}" =~ ^([wW])$ ]] ; then
|
||||||
|
@ -198,7 +198,7 @@ elif [[ "${action}" =~ ^([dD])$ ]] ; then
|
||||||
read -p "
|
read -p "
|
||||||
Username to delete? " username
|
Username to delete? " username
|
||||||
else
|
else
|
||||||
username="${2}"
|
username="${2}"
|
||||||
fi
|
fi
|
||||||
write_pass
|
write_pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue