diff options
author | Nova li Gensokyo <novaburst@kalli.st> | 2021-12-05 17:20:02 +0000 |
---|---|---|
committer | Nova li Gensokyo <novaburst@kalli.st> | 2021-12-05 17:20:02 +0000 |
commit | 03f80f481692bf7fca7673e8f60bd48c4888b2a6 (patch) | |
tree | c5cc7d997adb62f5c65734d4b90f6b76fcf676ea | |
parent | aa20a2b4ad6326e2b05f27416779e901c6f9016a (diff) | |
download | ayu-03f80f481692bf7fca7673e8f60bd48c4888b2a6.tar.gz |
His heart was yours from the first moment that you met.
-rwxr-xr-x | ayu | 33 | ||||
-rw-r--r-- | makefile | 7 |
2 files changed, 31 insertions, 9 deletions
diff --git a/ayu b/ayu index 606998f..03651b3 100755 --- a/ayu +++ b/ayu @@ -16,23 +16,26 @@ test -d $ayu_store || mkdir -p $ayu_store if ! [ -f $ayu_key ];then printf "First generate your own age(1) key with age-keygen(1) and place it as $ayu_key. \n" + printf "e.g: age-keygen -o $ayu_key \n" exit 1 fi cd $ayu_store +edit() { + age --decrypt --identity=$ayu_key --output=${1%%.age} ${1%%.age}.age + vi ${1%%.age} + age --encrypt -R $ayu_pub --output=${1%%.age}.age ${1%%.age} +} + list() { tree $ayu_store } -edit() { +new() { test -d "$1" && usage && exit tmpfile="$(mktemp)" - - # if the password already exists, decrypt and edit it instead - test -f "${1%%.age}".age && age --decrypt --identity=$age_pub "${1%%.age}".age > $tmpfile - vi "$tmpfile" mkdir -p "$(dirname "$1")" @@ -41,9 +44,12 @@ edit() { mv $tmpfile.age "${1%%.age}".age rm $tmpfile } - +remove() { + test -d "$1" && usage && exit + rm -r "$(dirname "$1")" +} usage() { - printf "$0 [ edit | list | new | view ] \n" + printf "$0 [ list | new | rm | usage | view ] \n" } view() { @@ -57,11 +63,20 @@ view() { fi } case $1 in + edit) + edit $2 + ;; list) list ;; - edit | new) - edit $2 + new) + new $2 + ;; + rm) + remove $2 + ;; + usage) + usage ;; view) view $2 diff --git a/makefile b/makefile new file mode 100644 index 0000000..c7e1edd --- /dev/null +++ b/makefile @@ -0,0 +1,7 @@ +destdir ?= +prefix ?= /usr/local + +install: + install -Dm0755 ayu $(destdir)$(prefix)/bin/ayu +uninstall: + rm -f $(destdir)$(prefix)/bin/ayu |