summaryrefslogtreecommitdiff
path: root/angou
diff options
context:
space:
mode:
authorkar <kar@13f0.net>2024-07-07 19:36:00 -0400
committerkar <kar@13f0.net>2024-08-25 15:14:52 -0400
commit2eb015f85ad09584143278b1a39a7b940f96d11e (patch)
tree517253ecab3f0bb0d7c19b4af917b948db2c66c8 /angou
parent479f4b920a9d3426b6ddee0d65e4539fd636d5df (diff)
add 'pass' command that views first line without newline
Diffstat (limited to 'angou')
-rwxr-xr-xangou14
1 files changed, 11 insertions, 3 deletions
diff --git a/angou b/angou
index c1d06fc..68056dc 100755
--- a/angou
+++ b/angou
@@ -25,11 +25,18 @@ view() {
25 fi 25 fi
26} 26}
27 27
28# view the first line
29view_single() {
30 [ ! -f $1 ] && usage && exit
31
32 view "$1" | sed 1q | tr -d \\n
33}
34
28# copy the first line from view to clipboard 35# copy the first line from view to clipboard
29copy() { 36copy() {
30 [ ! -f $1 ] && usage && exit 37 [ ! -f $1 ] && usage && exit
31 38
32 view "$1" | sed 1q | $ANGOU_CLIPBOARD 39 view_single "$1" | $ANGOU_CLIPBOARD
33} 40}
34 41
35# create new or existing password in ANGOU_DIR 42# create new or existing password in ANGOU_DIR
@@ -46,7 +53,7 @@ edit() {
46 # edit a copy of a password if it already exists 53 # edit a copy of a password if it already exists
47 [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile" 54 [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile"
48 55
49 "${VISUAL:-${EDITOR:-ed}}" "$tmpfile" 56 ${VISUAL:-${EDITOR:-ed}} "$tmpfile"
50 57
51 mkdir -p "$(dirname "$1")" 58 mkdir -p "$(dirname "$1")"
52 $ANGOU_ENCRYPT "$tmpfile" >"$1" 59 $ANGOU_ENCRYPT "$tmpfile" >"$1"
@@ -54,7 +61,7 @@ edit() {
54 61
55# print usage 62# print usage
56usage() { 63usage() {
57 printf "Usage: %s [help|copy|edit|generate|view [file or directory]]\n" "$0" 64 printf "Usage: %s [help|copy|edit|generate|view|view_single [file or directory]]\n" "$0"
58 printf "\tThe edit and copy command expects a file as an argument,\n" 65 printf "\tThe edit and copy command expects a file as an argument,\n"
59 printf "\twhile the view command expects a directory as an argument.\n" 66 printf "\twhile the view command expects a directory as an argument.\n"
60 printf "\tThe arguments for view and edit are relative to\n" 67 printf "\tThe arguments for view and edit are relative to\n"
@@ -71,5 +78,6 @@ case "$option" in
71 edit) edit "$2" ;; 78 edit) edit "$2" ;;
72 generate) edit "$2" generate ;; 79 generate) edit "$2" generate ;;
73 view) view "$2" ;; 80 view) view "$2" ;;
81 pass) view_single "$2" ;;
74 *) view "$1" ;; 82 *) view "$1" ;;
75esac 83esac