diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-02-06 20:52:22 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-02-06 20:52:22 +0100 |
commit | 35f7f2eaf307fd9f563623ceaaf88ce939cde282 (patch) | |
tree | b12fe3bae5d3d5b44986b5c6cd5f236643430c24 | |
parent | 96cab3d8e8ff7f236b23c3429fea80a0d25b7837 (diff) |
Revert "show: allow passing prefix to clip"
This reverts commit fcb92ed69fc191e39379bad715371d8c28410885.
Needs more discussion.
-rw-r--r-- | man/pass.1 | 9 | ||||
-rwxr-xr-x | src/password-store.sh | 14 |
2 files changed, 9 insertions, 14 deletions
@@ -86,13 +86,12 @@ List names of passwords inside the tree that match \fIpass-names\fP by using the .BR tree (1) program. This command is alternatively named \fBsearch\fP. .TP -\fBshow\fP [ \fI--clip\fP[=\fIline\fP], \fI-c\fP[\fIline\fP] ] \fIpass-name\fP +\fBshow\fP [ \fI--clip\fP[=\fIline-number\fP], \fI-c\fP[\fIline-number\fP] ] \fIpass-name\fP Decrypt and print a password named \fIpass-name\fP. If \fI--clip\fP or \fI-c\fP -is specified, do not print the password but instead copy a line to the clipboard using +is specified, do not print the password but instead copy the first (or otherwise specified) +line to the clipboard using .BR xclip (1) -and then restore the clipboard after 45 (or \fIPASSWORD_STORE_CLIP_TIME\fP) seconds. If -\fIline\fP is a number, the \fIline\fP-th line is copied; otherwise the line starting with -\fIline\fP is copied. +and then restore the clipboard after 45 (or \fIPASSWORD_STORE_CLIP_TIME\fP) seconds. .TP \fBinsert\fP [ \fI--echo\fP, \fI-e\fP | \fI--multiline\fP, \fI-m\fP ] [ \fI--force\fP, \fI-f\fP ] \fIpass-name\fP Insert a new password into the password store called \fIpass-name\fP. This will diff --git a/src/password-store.sh b/src/password-store.sh index 032df7f..a28b128 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -224,7 +224,7 @@ cmd_usage() { List passwords. $PROGRAM find pass-names... List passwords that match pass-names. - $PROGRAM [show] [--clip[=line],-c[line]] pass-name + $PROGRAM [show] [--clip[=line-number],-c[line-number]] pass-name Show existing password and optionally put it on the clipboard. If put on the clipboard, it will be cleared in $CLIP_TIME seconds. $PROGRAM grep search-string @@ -304,7 +304,7 @@ cmd_show() { --) shift; break ;; esac done - [[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND [--clip[=line],-c[line]] [pass-name]" + [[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND [--clip[=line-number],-c[line-number]] [pass-name]" local path="$1" local passfile="$PREFIX/$path.gpg" @@ -313,13 +313,9 @@ cmd_show() { if [[ $clip -eq 0 ]]; then $GPG -d "${GPG_OPTS[@]}" "$passfile" || exit $? else - local pass - if [[ $clip_location =~ ^[0-9]+$ ]]; then - pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +${clip_location} | head -n 1)" - else - pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep -m 1 "^${clip_location}")" - fi - [[ -n $pass ]] || die "There is no password to put on the clipboard at line '${clip_location}'." + [[ $clip_location =~ ^[0-9]+$ ]] || die "Clip location '$clip_location' is not a number." + local pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +${clip_location} | head -n 1)" + [[ -n $pass ]] || die "There is no password to put on the clipboard at line ${clip_location}." clip "$pass" "$path" fi elif [[ -d $PREFIX/$path ]]; then |