diff options
author | Aoi Koizumi <novaburst@kalli.st> | 2022-04-02 16:39:40 -0300 |
---|---|---|
committer | Aoi Koizumi <novaburst@kalli.st> | 2022-04-02 16:39:40 -0300 |
commit | aa5ae0c8e5eb613662e0c4e7f9bae2686cbc18dc (patch) | |
tree | d408e4d56daf556670a49f08cb9c506132eae04f | |
parent | 35c0bd2601d222629a66919a0d859bad956f5c6c (diff) | |
download | ayu-aa5ae0c8e5eb613662e0c4e7f9bae2686cbc18dc.tar.gz |
Linted 'ayu' code, update manual page
Signed-off-by: Aoi Koizumi <novaburst@kalli.st>
-rw-r--r-- | ayu | 52 | ||||
-rw-r--r-- | ayu.mdoc | 12 |
2 files changed, 38 insertions, 26 deletions
diff --git a/ayu b/ayu index 6516ad8..d33db1c 100644 --- a/ayu +++ b/ayu @@ -1,31 +1,33 @@ #!/bin/sh +set -e + +# 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} -for dir in $ayu_dir $ayu_settings $ayu_store; do - test -d $dir || mkdir -p $dir +for dir in "$ayu_dir" "$ayu_settings" "$ayu_store"; do + test -d "$dir" || mkdir -p "$dir" done -if ! test -f $ayu_settings/config; then - { - printf "#ayu_clipboard=\"wl-copy --primary\"\n" - printf "ayu_clipboard=\"xsel -ib\"\n" - printf "ayu_private_key=\"${ayu_dir}/private_key\" \n" - printf "ayu_public_key=\"${ayu_dir}/public_key\" \n" - printf "EDITOR=${EDITOR:-vi}\n" - } > $ayu_settings/config - - . $ayu_settings/config +if ! test -f "$ayu_settings"/config; then + cat << EOF > "$ayu_settings"/config + #ayu_clipboard=$(wl-copy --primary) + #ayu_clipboard=$(xsel -ib) + ayu_private_key=${ayu_dir}/private_key + ayu_public_key=${ayu_dir}/public_key + EDITOR=${EDITOR:-vi} +EOF +. "$ayu_settings"/config else - . $ayu_settings/config + . "$ayu_settings"/config fi cd "$ayu_store" || exit 1 fn_copy() { - view "$2" | sed 1q | "$ayu_clipboard" + fn_view "$2" | "$ayu_clipboard" } fn_edit() { age --decrypt --identity="${ayu_private_key}" --output="${1%%.age}" "${1%%.age}.age" @@ -37,7 +39,7 @@ fn_list() { tree "$ayu_store" } fn_new() { - test -d "$1" && usage && exit + test -d "$1" && fn_usage && exit tmpfile="$(mktemp)" ${EDITOR} "$tmpfile" @@ -58,9 +60,9 @@ fn_usage() { printf "Usage: [ -c | -e | -l | -n | -r | -R | -v ] <entry> \n" } fn_view() { - if [ -f "${1%%.age}".age ];then + if [ -f "${1%%.age}".age ]; then age --decrypt --identity="${ayu_private_key}" "${1%%.age}.age" - elif [ -d "${1:-.}" ];then + elif [ -d "${1:-.}" ]; then tree "${1:-.}" else fn_usage @@ -68,12 +70,12 @@ fn_view() { fi } 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 diff --git a/ayu.mdoc b/ayu.mdoc index 50a43a2..b5d75d4 100644 --- a/ayu.mdoc +++ b/ayu.mdoc @@ -1,4 +1,4 @@ -.Dd March 14, 2022 +.Dd March 23, 2022 .Dt ayu 1 .Os .Sh NAME @@ -77,3 +77,13 @@ Defaults to .Sh AUTHORS .An Aoi Koizumi .Mt novaburst@kalli.st +.Sh BUGS +Under the Wayland display server, +.Nm ayu +.Sy -c +won't work well because of +"Permmission denied" errors. +.Pp +However +.Xr xsel 1 +on X11 should work fine. |