spm

Personal fork of spm (simple password manager)
git clone git@getsh.org:spm.git
Log | Files | Refs | README | LICENSE

commit 5aa72ae44f05096bc60707ace5cf09ca8a64a51a
parent 66fdd2c61352bcb2acb18292eea8e3715e972344
Author: Klemens Nanni <kl3@posteo.org>
Date:   Thu, 16 Jun 2016 23:57:52 +0200

Create 'view' helper function, improve error message

Diffstat:
Mspm.sh | 21+++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/spm.sh b/spm.sh @@ -33,7 +33,7 @@ check() { [ -z "${entry}" ] && die 'No such entry' [ "$(printf '%s' "${entry}" | wc -l)" -gt 0 ] \ - && die 'Too ambigious keyword' + && die "Too ambigious keyword. Try 'spm search'" } gpg() { @@ -48,11 +48,16 @@ readpw() { [ -z "${2}" ] && die 'No password specified' } -search() { +_search() { find "${STORE_DIR}" \( -type f -o -type l \) \ -iwholename "*${1}*".gpg } +view() { + sed s/.gpg//g | less -E -i -K -R -X +} + + ## Commands add() { @@ -73,18 +78,22 @@ list() { tree ${grps_only:+-d} --noreport -l --dirsfirst --sort=name -C \ -- "${STORE_DIR}/${1}" \ - | sed s/.gpg//g \ - | less -E -i -K -R -X + | view } del() { - entry=$(search "${1}" | head -n2) + entry=$(_search "${1}" | head -n2) check rm -i "${entry}"; printf '\n' } +search() { + _search "${1}" \ + | view +} + show() { - entry=$(search "${1}" | head -n2) + entry=$(_search "${1}" | head -n2) check gpg --decrypt "${entry}" }