diff --git a/README.md b/README.md index aee03c9..a769397 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,8 @@ Script to manage passwords in an encrypted file using gpg. # Installation git clone https://github.com/drduh/pwd.sh && cd pwd.sh - -Requires `gpg` -Install with `brew install gpg` or `sudo apt-get install gnupg` or build and install it from [source](https://www.gnupg.org/download/index.html). +Requires `gpg`. Install with `brew install gpg` or `sudo apt-get install gnupg` or build and install it from [source](https://www.gnupg.org/download/index.html). # Use @@ -22,10 +20,14 @@ Type `r` to read a password(s). Type `d` to delete a password. -Or, the action and username can be passed on the command line, e.g., +Options can also be passed on the command line, e.g., -`./pwd.sh r github` or `./pwd.sh w gmail` +`./pwd.sh w gmail 30` to generate and write a password called 'gmail' with a length of 30 characters, or -The encrypted file `pwd.sh.safe` and script can be safely shared between machines over public channels (Google Drive, Dropbox, etc). +`./pwd.sh r github` to read the password called 'github', or + +`./pwd.sh d dropbox` to delete the password called 'dropbox'. + +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. diff --git a/pwd.sh b/pwd.sh index 66639d1..06a7302 100755 --- a/pwd.sh +++ b/pwd.sh @@ -95,8 +95,13 @@ gen_pass () { len=50 max=100 - read -p " + + if [[ -z "${3+x}" ]] ; then + read -p " Password length? (default: ${len}, max: ${max}) " length + else + length="${3}" + fi if [[ ${length} =~ ^[0-9]+$ ]] ; then len=${length} @@ -142,11 +147,15 @@ create_username () { if [[ -z "${2+x}" ]] ; then read -p " Username: " username + else + username="${2}" + fi + + if [[ -z "${3+x}" ]] ; then read -p " Generate password? (y/n, default: y) " rand_pass else rand_pass="" - username="${2}" fi if [[ "${rand_pass}" =~ ^([nN][oO]|[nN])$ ]]; then @@ -154,7 +163,7 @@ create_username () { Enter password for \"${username}\": " ; echo userpass=$password else - userpass=$(gen_pass) + userpass=$(gen_pass "$@") echo " Password: ${userpass}" fi