all repos — pw @ 68efa8d4af4694f8da16622faf1b02cdb13307cc

minimal password store

Merge upstream
Anirudh Oppiliappan x@icyphox.sh
Mon, 18 Nov 2019 10:23:17 +0530
commit

68efa8d4af4694f8da16622faf1b02cdb13307cc

parent

1f8f54198a72a8b76c61e0d80db78ed7014747a5

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 }

@@ -36,7 +36,7 @@ }

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

@@ -59,7 +59,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" }

@@ -77,7 +77,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.

@@ -106,11 +106,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"

@@ -121,7 +122,7 @@ d) del "$OPTARG" ;;

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