From 27eb27e8380d096f73a697de2e8641db471b3aa9 Mon Sep 17 00:00:00 2001 From: Aoi Koizumi Date: Thu, 28 Apr 2022 09:29:08 -0300 Subject: Reformatted the whole thing yet again --- ayu | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'ayu') diff --git a/ayu b/ayu index d33db1c..85fa41b 100644 --- a/ayu +++ b/ayu @@ -1,16 +1,21 @@ #!/bin/sh + +# Exit on error set -e +# Disabling some shellcheck stuff here as I won't really solve it anyway. # shellcheck disable=SC2154,SC1091 ayu_dir=${ayu_dir:-$HOME/.ayu} ayu_settings=${ayu_settings:-$XDG_CONFIG_HOME/ayu} ayu_store=${ayu_store:-$HOME/.ayu-store} +# Check if the above directories exist, otherwise create them for dir in "$ayu_dir" "$ayu_settings" "$ayu_store"; do test -d "$dir" || mkdir -p "$dir" done +# Same thing for the configuration file if ! test -f "$ayu_settings"/config; then cat << EOF > "$ayu_settings"/config #ayu_clipboard=$(wl-copy --primary) @@ -24,8 +29,11 @@ else . "$ayu_settings"/config fi +# Switch directory to the store, else bail out cd "$ayu_store" || exit 1 +## THEGOODS ## + fn_copy() { fn_view "$2" | "$ayu_clipboard" } @@ -69,13 +77,16 @@ fn_view() { exit fi } +## SDOOGEHT ## + +## 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" ;; -*) fn_usage ;; + -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" ;; + *) fn_usage ;; esac -- cgit 1.4.1-2-gfad0