diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2016-01-08 23:57:45 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-06-23 23:55:22 +0200 |
commit | 295b968d5a3802bf3a16225ea2b216855f49630e (patch) | |
tree | 0e7060e80e665c8678141b0fd06998802cc02843 | |
parent | 3dd14690c7c81ac80e32e942cf5976732faf0fb3 (diff) | |
download | pass-295b968d5a3802bf3a16225ea2b216855f49630e.tar.gz pass-295b968d5a3802bf3a16225ea2b216855f49630e.tar.bz2 pass-295b968d5a3802bf3a16225ea2b216855f49630e.zip |
Allow passing '-u' to 'show' to print the 'User:' line
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 a0dcf2e..1da953c 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/.." @@ -267,6 +268,8 @@ cmd_version() { = Jason A. Donenfeld = = Jason@zx2c4.com = = = + = with Nec's modifications = + = = = http://www.passwordstore.org/ = ============================================ _EOF @@ -366,13 +369,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 @@ -386,6 +390,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 $? |