aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnirudh Oppiliappan <x@icyphox.sh>2019-11-18 10:23:17 +0530
committerAnirudh Oppiliappan <x@icyphox.sh>2019-11-18 10:23:17 +0530
commit68efa8d4af4694f8da16622faf1b02cdb13307cc (patch)
tree37b4b7c875d497e7a1af5633b98dd30d11fbd9bd
parent1f8f54198a72a8b76c61e0d80db78ed7014747a5 (diff)
parenta820d637b23254aa6d7bd0353c31612206a82939 (diff)
downloadpw-68efa8d4af4694f8da16622faf1b02cdb13307cc.tar.gz
Merge upstream
-rwxr-xr-xpw13
1 files changed, 7 insertions, 6 deletions
diff --git a/pw b/pw
index b6197f6..90be310 100755
--- a/pw
+++ b/pw
@@ -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
37list() { 37list() {
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
60copy() { 60copy() {
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
83Requires PW_KEY to be set. Optionally, set PW_DIR for custom directory location. 83Requires 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