summaryrefslogtreecommitdiff
path: root/src/password-store.sh
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-02-06 20:04:24 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-02-06 20:04:24 +0100
commitfcb92ed69fc191e39379bad715371d8c28410885 (patch)
treee4492d39b6410f89c63f587426dc72bee0fa9150 /src/password-store.sh
parent930f01cd830815730f3f041d5e5788fccdd6d4cb (diff)
downloadpass-fcb92ed69fc191e39379bad715371d8c28410885.tar.gz
pass-fcb92ed69fc191e39379bad715371d8c28410885.tar.bz2
pass-fcb92ed69fc191e39379bad715371d8c28410885.zip
show: allow passing prefix to clip
Diffstat (limited to '')
-rwxr-xr-xsrc/password-store.sh14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index a6b3400..7e9fcb0 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-number],-c[line-number]] pass-name
+ $PROGRAM [show] [--clip[=line],-c[line]] 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-number],-c[line-number]] [pass-name]"
+ [[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND [--clip[=line],-c[line]] [pass-name]"
local path="$1"
local passfile="$PREFIX/$path.gpg"
@@ -313,9 +313,13 @@ cmd_show() {
if [[ $clip -eq 0 ]]; then
$GPG -d "${GPG_OPTS[@]}" "$passfile" || exit $?
else
- [[ $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}."
+ 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 "$pass" "$path"
fi
elif [[ -d $PREFIX/$path ]]; then