diff options
Diffstat (limited to '')
-rwxr-xr-x | src/password-store.sh | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/password-store.sh b/src/password-store.sh index 77f3eda..2a4a55c 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -19,6 +19,7 @@ CLIP_TIME="${PASSWORD_STORE_CLIP_TIME:-45}" GENERATED_LENGTH="${PASSWORD_STORE_GENERATED_LENGTH:-25}" CHARACTER_SET="${PASSWORD_STORE_CHARACTER_SET:-[:punct:][:alnum:]}" CHARACTER_SET_NO_SYMBOLS="${PASSWORD_STORE_CHARACTER_SET_NO_SYMBOLS:-[:alnum:]}" +USER_STRING="${PASSWORD_USER_STRING:-User: }" unset GIT_DIR GIT_WORK_TREE GIT_NAMESPACE GIT_INDEX_FILE GIT_INDEX_VERSION GIT_OBJECT_DIRECTORY GIT_COMMON_DIR export GIT_CEILING_DIRECTORIES="$PREFIX/.." @@ -265,6 +266,8 @@ cmd_version() { = Jason A. Donenfeld = = Jason@zx2c4.com = = = + = with Nec's modifications = + = = = http://www.passwordstore.org/ = ============================================ _EOF @@ -364,13 +367,14 @@ cmd_init() { } cmd_show() { - local opts selected_line clip=0 qrcode=0 - opts="$($GETOPT -o q::c:: -l qrcode::,clip:: -n "$PROGRAM" -- "$@")" + local opts selected_line clip=0 qrcode=0 user=0 + opts="$($GETOPT -o q::c::u -l qrcode::,clip::,user -n "$PROGRAM" -- "$@")" local err=$? eval set -- "$opts" while true; do case $1 in -q|--qrcode) qrcode=1; selected_line="${2:-1}"; shift 2 ;; -c|--clip) clip=1; selected_line="${2:-1}"; shift 2 ;; + -u|--user) user=1; shift 1;; --) shift; break ;; esac done @@ -384,6 +388,18 @@ cmd_show() { if [[ $clip -eq 0 && $qrcode -eq 0 ]]; then pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | $BASE64)" || exit $? echo "$pass" | $BASE64 -d + elif [[ $user -eq 1 ]]; then + local user="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep -m 1 "^${USER_STRING}" | sed -e "s/^${USER_STRING}"'\(.*\)/\1/')" + + [[ -n $user ]] || exit 1 + + if [[ $clip -eq 1 ]]; then + clip "$user" "$path" + elif [[ $qrcode -eq 1 ]]; then + qrcode "$pass" "$path" + else + echo "$user" + fi else [[ $selected_line =~ ^[0-9]+$ ]] || die "Clip location '$selected_line' is not a number." pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +${selected_line} | head -n 1)" || exit $? |