kasi

POSIX shell password manager that is cryptography program-agnostic
Log | Files | Refs | README | LICENSE

commit 2eb015f85ad09584143278b1a39a7b940f96d11e
parent 479f4b920a9d3426b6ddee0d65e4539fd636d5df
Author: kar <kar@13f0.net>
Date:   Sun,  7 Jul 2024 19:36:00 -0400

add 'pass' command that views first line without newline

Diffstat:
Mangou | 14+++++++++++---
Mcontrib/autocomplete.ksh | 2+-
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/angou b/angou @@ -25,11 +25,18 @@ view() { fi } +# view the first line +view_single() { + [ ! -f $1 ] && usage && exit + + view "$1" | sed 1q | tr -d \\n +} + # copy the first line from view to clipboard copy() { [ ! -f $1 ] && usage && exit - view "$1" | sed 1q | $ANGOU_CLIPBOARD + view_single "$1" | $ANGOU_CLIPBOARD } # create new or existing password in ANGOU_DIR @@ -46,7 +53,7 @@ edit() { # edit a copy of a password if it already exists [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile" - "${VISUAL:-${EDITOR:-ed}}" "$tmpfile" + ${VISUAL:-${EDITOR:-ed}} "$tmpfile" mkdir -p "$(dirname "$1")" $ANGOU_ENCRYPT "$tmpfile" >"$1" @@ -54,7 +61,7 @@ edit() { # print usage usage() { - printf "Usage: %s [help|copy|edit|generate|view [file or directory]]\n" "$0" + printf "Usage: %s [help|copy|edit|generate|view|view_single [file or directory]]\n" "$0" printf "\tThe edit and copy command expects a file as an argument,\n" printf "\twhile the view command expects a directory as an argument.\n" printf "\tThe arguments for view and edit are relative to\n" @@ -71,5 +78,6 @@ case "$option" in edit) edit "$2" ;; generate) edit "$2" generate ;; view) view "$2" ;; + pass) view_single "$2" ;; *) view "$1" ;; esac diff --git a/contrib/autocomplete.ksh b/contrib/autocomplete.ksh @@ -1,4 +1,4 @@ #!/bin/ksh -set -A complete_angou_1 -- help copy edit view generate +set -A complete_angou_1 -- help copy edit view pass generate set -A complete_angou_2 -- $(find ${ANGOU_DIR:-~/.angou} -type f | sort \ | sed s,${ANGOU_DIR}/,, | sed s,\\.gpg$,,)