diff options
| author | Shokara Kou <kou@13f0.net> | 2022-10-13 19:04:45 -0400 |
|---|---|---|
| committer | Shokara Kou <kou@13f0.net> | 2022-10-13 19:04:45 -0400 |
| commit | 3b937958ac383b05761c9a16bcf5cc9003cd6031 (patch) | |
| tree | a8cfa131012f31800ec170679035879291684c04 /angou | |
| parent | 32341a174c86712cabb9243caf9e88f4d7feec50 (diff) | |
add generate function and contrib/random script
I sometimes forget to copy-paste the passwords and usernames I
generate, so this should help with that. Uses the random string
generator script I made before by default.
Diffstat (limited to 'angou')
| -rwxr-xr-x | angou | 11 |
1 files changed, 10 insertions, 1 deletions
| @@ -6,6 +6,9 @@ ANGOU_DIR=${ANGOU_DIR:-"$HOME/.angou/"} | |||
| 6 | ANGOU_CLIPBOARD=${ANGOU_CLIPBOARD:-"xsel -i"} | 6 | ANGOU_CLIPBOARD=${ANGOU_CLIPBOARD:-"xsel -i"} |
| 7 | # sets command to use when listing directory structure | 7 | # sets command to use when listing directory structure |
| 8 | ANGOU_LIST=${ANGOU_LIST:-"tree"} | 8 | ANGOU_LIST=${ANGOU_LIST:-"tree"} |
| 9 | # custom command for generating passwords/users | ||
| 10 | ANGOU_GEN_PASS=${ANGOU_GEN_PASS:-"random pass"} | ||
| 11 | ANGOU_GEN_USER=${ANGOU_GEN_USER:-"random user"} | ||
| 9 | 12 | ||
| 10 | mkdir -p "$ANGOU_DIR" | 13 | mkdir -p "$ANGOU_DIR" |
| 11 | cd "$ANGOU_DIR" || exit | 14 | cd "$ANGOU_DIR" || exit |
| @@ -35,6 +38,11 @@ edit() { | |||
| 35 | 38 | ||
| 36 | tmpfile="$(mktemp)" | 39 | tmpfile="$(mktemp)" |
| 37 | 40 | ||
| 41 | if [ "$2" = "generate" ]; then | ||
| 42 | $ANGOU_GEN_PASS >"$tmpfile" | ||
| 43 | echo "Username: $($ANGOU_GEN_USER)" >>"$tmpfile" | ||
| 44 | fi | ||
| 45 | |||
| 38 | # edit a copy of a password if it already exists | 46 | # edit a copy of a password if it already exists |
| 39 | [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile" | 47 | [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile" |
| 40 | 48 | ||
| @@ -46,7 +54,7 @@ edit() { | |||
| 46 | 54 | ||
| 47 | # print usage | 55 | # print usage |
| 48 | usage() { | 56 | usage() { |
| 49 | printf "Usage: %s [help|copy|edit|view [file or directory]]\n" "$0" | 57 | printf "Usage: %s [help|copy|edit|generate|view [file or directory]]\n" "$0" |
| 50 | printf "\tThe edit and copy command expects a file as an argument,\n" | 58 | printf "\tThe edit and copy command expects a file as an argument,\n" |
| 51 | printf "\twhile the view command expects a directory as an argument.\n" | 59 | printf "\twhile the view command expects a directory as an argument.\n" |
| 52 | printf "\tThe arguments for view and edit are relative to\n" | 60 | printf "\tThe arguments for view and edit are relative to\n" |
| @@ -61,6 +69,7 @@ case "$option" in | |||
| 61 | help) usage ;; | 69 | help) usage ;; |
| 62 | copy) copy "$2" ;; | 70 | copy) copy "$2" ;; |
| 63 | edit) edit "$2" ;; | 71 | edit) edit "$2" ;; |
| 72 | generate) edit "$2" generate ;; | ||
| 64 | view) view "$2" ;; | 73 | view) view "$2" ;; |
| 65 | *) view "$1" ;; | 74 | *) view "$1" ;; |
| 66 | esac | 75 | esac |
