diff options
Diffstat (limited to 'pw')
-rwxr-xr-x | pw | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -9,7 +9,7 @@ init() { | |||
9 | mkdir -p "$PW_DIR" | 9 | mkdir -p "$PW_DIR" |
10 | echo "pw: password directory initialized at $PW_DIR" | 10 | echo "pw: password directory initialized at $PW_DIR" |
11 | else | 11 | else |
12 | echo "PW_DIR is $PW_DIR" | 12 | echo "PW_DIR is $PW_DIR" |
13 | die "$PW_DIR exists" | 13 | die "$PW_DIR exists" |
14 | fi | 14 | fi |
15 | } | 15 | } |
@@ -36,7 +36,7 @@ add() { | |||
36 | 36 | ||
37 | list() { | 37 | list() { |
38 | for f in "$PW_DIR"/*.gpg; do | 38 | for f in "$PW_DIR"/*.gpg; do |
39 | printf '%s\n' "$(basename ${f%.gpg})" | 39 | printf '%s\n' "$(basename "${f%.gpg}")" |
40 | done | 40 | done |
41 | } | 41 | } |
42 | 42 | ||
@@ -59,7 +59,7 @@ show() { | |||
59 | 59 | ||
60 | copy() { | 60 | copy() { |
61 | checkf "$PW_DIR/$1.gpg" | 61 | checkf "$PW_DIR/$1.gpg" |
62 | show "$1" | xclip -selection clipboard | 62 | show "$1" | xclip -rmlastnl -selection clipboard |
63 | echo "pw: copied $1 to clipboard" | 63 | echo "pw: copied $1 to clipboard" |
64 | } | 64 | } |
65 | 65 | ||
@@ -77,7 +77,7 @@ options: | |||
77 | -s Print password to STDOUT. | 77 | -s Print password to STDOUT. |
78 | -l List out all passwords. | 78 | -l List out all passwords. |
79 | -c Copy existing password to clipboard. | 79 | -c Copy existing password to clipboard. |
80 | -d Delete password. | 80 | -d Delete password. |
81 | -h Display this help message and exit. | 81 | -h Display this help message and exit. |
82 | 82 | ||
83 | Requires PW_KEY to be set. Optionally, set PW_DIR for custom directory location. | 83 | Requires PW_KEY to be set. Optionally, set PW_DIR for custom directory location. |
@@ -106,11 +106,12 @@ main() { | |||
106 | 106 | ||
107 | while getopts "ila:g:s:c:d:h" options | 107 | while getopts "ila:g:s:c:d:h" options |
108 | do | 108 | do |
109 | # shellcheck disable=SC2221,SC2222 | ||
109 | case "$options" in | 110 | case "$options" in |
110 | i) init ;; | 111 | i) init ;; |
111 | l) list ;; | 112 | l) list ;; |
112 | g) add "$OPTARG" ;; | 113 | g) add "$OPTARG" ;; |
113 | a) | 114 | a) |
114 | read -rsp "enter password: " pass | 115 | read -rsp "enter password: " pass |
115 | printf "\n" | 116 | printf "\n" |
116 | add "$OPTARG" "$pass" | 117 | add "$OPTARG" "$pass" |
@@ -121,7 +122,7 @@ main() { | |||
121 | *|h) usage ;; | 122 | *|h) usage ;; |
122 | esac | 123 | esac |
123 | done | 124 | done |
124 | 125 | ||
125 | shift $(( OPTIND -1 )) | 126 | shift $(( OPTIND -1 )) |
126 | } | 127 | } |
127 | 128 | ||