summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xangou10
1 files changed, 8 insertions, 2 deletions
diff --git a/angou b/angou
index f5e1f2a..b7427ba 100755
--- a/angou
+++ b/angou
@@ -10,6 +10,9 @@ 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
13# decrypt and print a password from ANGOU_DIR or print the directory structure 16# decrypt and print a password from ANGOU_DIR or print the directory structure
14view() { 17view() {
15 if [ -f "${1%%.gpg}" ]; then 18 if [ -f "${1%%.gpg}" ]; then
@@ -36,12 +39,15 @@ edit() {
36 tmpfile="$(mktemp)" 39 tmpfile="$(mktemp)"
37 40
38 # edit a copy of a password if it already exists 41 # edit a copy of a password if it already exists
39 [ -f "${1%%.gpg}".gpg ] && cp "$1" "$tmpfile" 42 [ -f "${1%%.gpg}".gpg ] && gpg -qd "${1%%.gpg}".gpg > "$tmpfile"
40 43
41 "${VISUAL:-${EDITOR:-ed}}" "$tmpfile" 44 "${VISUAL:-${EDITOR:-ed}}" "$tmpfile"
42 45
43 mkdir -p "$(dirname "$1")" 46 mkdir -p "$(dirname "$1")"
44 mv "$tmpfile" "${1%%.gpg}".gpg 47 gpg -er "$GPG_ID" "$tmpfile"
48
49 rm "$tmpfile"
50 mv "$tmpfile.gpg" "${1%%.gpg}".gpg
45} 51}
46 52
47# print usage 53# print usage