summaryrefslogtreecommitdiff
path: root/angou
diff options
context:
space:
mode:
authorShokara Kou <kou@13f0.net>2022-09-07 18:42:36 -0400
committerShokara Kou <kou@13f0.net>2022-09-07 18:42:36 -0400
commit32341a174c86712cabb9243caf9e88f4d7feec50 (patch)
tree6fa60f2b070406b95b30a39569588ac56ff83f81 /angou
parent46924111a8fb9e7a51bb3cb50f306b2334f46f24 (diff)
make angou-age the main angou to be tool-independent
Angou no longer strictly depends on age or gnupg as the encrypt and decrypt commands are user changeable.
Diffstat (limited to 'angou')
-rwxr-xr-xangou16
1 files changed, 5 insertions, 11 deletions
diff --git a/angou b/angou
index 5a252a3..845670b 100755
--- a/angou
+++ b/angou
@@ -10,13 +10,10 @@ ANGOU_LIST=${ANGOU_LIST:-"tree"}
10mkdir -p "$ANGOU_DIR" 10mkdir -p "$ANGOU_DIR"
11cd "$ANGOU_DIR" || exit 11cd "$ANGOU_DIR" || exit
12 12
13[ ! -f ".gpg-id" ] && echo "please put your gpg key id into \$ANGOU_DIR/.gpg-id"
14GPG_ID="$(cat .gpg-id)"
15
16# decrypt and print a password from ANGOU_DIR or print the directory structure 13# decrypt and print a password from ANGOU_DIR or print the directory structure
17view() { 14view() {
18 if [ -f "${1%%.gpg}".gpg ]; then 15 if [ -f "$1" ]; then
19 gpg -qd "${1%%.gpg}".gpg 16 $ANGOU_DECRYPT "$1"
20 elif [ -d "${1:-.}" ]; then 17 elif [ -d "${1:-.}" ]; then
21 tree "${1:-.}" 18 tree "${1:-.}"
22 else 19 else
@@ -27,7 +24,7 @@ view() {
27 24
28# copy the first line from view to clipboard 25# copy the first line from view to clipboard
29copy() { 26copy() {
30 [ ! -f "${1%%.gpg}".gpg ] && usage && exit 27 [ ! -f $1 ] && usage && exit
31 28
32 view "$1" | sed 1q | $ANGOU_CLIPBOARD 29 view "$1" | sed 1q | $ANGOU_CLIPBOARD
33} 30}
@@ -39,15 +36,12 @@ edit() {
39 tmpfile="$(mktemp)" 36 tmpfile="$(mktemp)"
40 37
41 # edit a copy of a password if it already exists 38 # edit a copy of a password if it already exists
42 [ -f "${1%%.gpg}".gpg ] && gpg -qd "${1%%.gpg}".gpg > "$tmpfile" 39 [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile"
43 40
44 "${VISUAL:-${EDITOR:-ed}}" "$tmpfile" 41 "${VISUAL:-${EDITOR:-ed}}" "$tmpfile"
45 42
46 mkdir -p "$(dirname "$1")" 43 mkdir -p "$(dirname "$1")"
47 gpg -er "$GPG_ID" "$tmpfile" 44 $ANGOU_ENCRYPT "$tmpfile" >"$1"
48
49 rm "$tmpfile"
50 mv "$tmpfile.gpg" "${1%%.gpg}".gpg
51} 45}
52 46
53# print usage 47# print usage