all repos — pw @ a820d637b23254aa6d7bd0353c31612206a82939

minimal password store

Fix shellcheck errors, make xclip copy without a newline (#2)

Azat Bahawi azahi@teknik.io
Mon, 18 Nov 2019 06:48:45 +0300
commit

a820d637b23254aa6d7bd0353c31612206a82939

parent

a5e5d403482e8fccf7d1f1502bbf1d72962be9d2

1 files changed, 7 insertions(+), 6 deletions(-)

jump to
M pwpw

@@ -9,7 +9,7 @@ if [[ ! -e "$PW_DIR" ]]; then

mkdir -p "$PW_DIR" echo "pw: password directory initialized at $PW_DIR" else - echo "PW_DIR is $PW_DIR" + echo "PW_DIR is $PW_DIR" die "$PW_DIR exists" fi }

@@ -35,7 +35,7 @@ }

list() { for f in "$PW_DIR"/*.gpg; do - printf '%s\n' "$(basename ${f%.gpg})" + printf '%s\n' "$(basename "${f%.gpg}")" done }

@@ -58,7 +58,7 @@ # TODO: rework having to checkf twice

copy() { checkf "$PW_DIR/$1.gpg" - show "$1" | xclip -selection clipboard + show "$1" | xclip -rmlastnl -selection clipboard echo "pw: copied $1 to clipboard" }

@@ -76,7 +76,7 @@ -g Generate a password.

-s Print password to STDOUT. -l List out all passwords. -c Copy existing password to clipboard. - -d Delete password. + -d Delete password. -h Display this help message and exit. Requires PW_KEY to be set. Optionally, set PW_DIR for custom directory location.

@@ -104,11 +104,12 @@ }

while getopts "ila:g:s:c:d:h" options do + # shellcheck disable=SC2221,SC2222 case "$options" in i) init ;; l) list ;; g) add "$OPTARG" ;; - a) + a) read -rsp "enter password: " pass printf "\n" add "$OPTARG" "$pass"

@@ -119,7 +120,7 @@ d) del "$OPTARG" ;;

*|h) usage ;; esac done - + shift $(( OPTIND -1 )) }