about summary refs log tree commit diff stats
path: root/ayu
diff options
context:
space:
mode:
authorAoi Koizumi <novaburst@kalli.st>2022-05-07 13:13:28 -0300
committerAoi Koizumi <novaburst@kalli.st>2022-05-07 13:13:28 -0300
commitea06da326231adc9c2e2dc88db54b5100c608867 (patch)
tree170e97e4be28baa4e1cd3a9bff6698170d2cd0b2 /ayu
parentfcc0f94031db0b83ba9b2cd85b4b678f6c3f2d5b (diff)
downloadayu-ea06da326231adc9c2e2dc88db54b5100c608867.tar.gz
Added aliases for subcommands, update manual page and added a new environment variable.
Signed-off-by: Aoi Koizumi <novaburst@kalli.st>
Diffstat (limited to 'ayu')
-rw-r--r--ayu19
1 files changed, 10 insertions, 9 deletions
diff --git a/ayu b/ayu
index fe50472..26287b3 100644
--- a/ayu
+++ b/ayu
@@ -20,6 +20,7 @@ if ! test -f "$ayu_settings"/config; then
     cat << EOF > "$ayu_settings"/config
 #ayu_clipboard=$(wl-copy --primary)
 #ayu_clipboard=$(xsel -ib)
+ayu_editor=${ayu_editor:-vi}
 ayu_private_key=${ayu_dir}/private_key
 ayu_public_key=${ayu_dir}/public_key
 EOF
@@ -38,7 +39,7 @@ fn_copy() {
 }
 fn_edit() {
     age --decrypt --identity="${ayu_private_key}" --output="${1%%.age}" "${1%%.age}.age"
-    $EDITOR "${1%%.age}"
+    ${ayu_editor} "${1%%.age}"
     age --encrypt --recipients-file "${ayu_public_key}" --output="${1%%.age}.age" "${1%%.age}"
     rm "${1%%.age}"
 }
@@ -49,7 +50,7 @@ fn_new() {
     test -d "$1" && fn_usage && exit
 
     tmpfile="$(mktemp)"
-    ${EDITOR} "$tmpfile"
+    ${ayu_editor} "$tmpfile"
 
     mkdir -p "$(dirname "$1")"
     age --encrypt --recipients-file "${ayu_public_key}" --output="$tmpfile.age" "$tmpfile"
@@ -80,12 +81,12 @@ fn_view() {
 
 ## Command line parsing (I don't get why this has be so difficult for say, Lua)
 case $1 in
-    -c) fn_copy "$2" ;;
-    -e) fn_edit "$2" ;;
-    -l) fn_list ;;
-    -n) fn_new "$2" ;;
-    -r) fn_remove_single "$2" ;;
-    -R) fn_remove_recursive "$2" ;;
-    -v) fn_view "$2" ;;
+    -c | copy) fn_copy "$2" ;;
+    -e | edit) fn_edit "$2" ;;
+    -l | list) fn_list ;;
+    -n | add) fn_new "$2" ;;
+    -r | del) fn_remove_single "$2" ;;
+    -R | delr) fn_remove_recursive "$2" ;;
+    -v | view) fn_view "$2" ;;
     *) fn_usage ;;
 esac