From 88f3ab499dfd8c7949017d7338f547ff5a7dfacf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 28 Jun 2025 04:36:16 +0200 Subject: [PATCH 1/7] file --- sh/file.sh | 26 ++++++++++++++++++++++++++ sh/main.sh | 8 ++++++-- sh/tmux.sh | 4 ++++ sh/util.sh | 25 +++---------------------- 4 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 sh/file.sh diff --git a/sh/file.sh b/sh/file.sh new file mode 100644 index 0000000..becca76 --- /dev/null +++ b/sh/file.sh @@ -0,0 +1,26 @@ +# ╭──────╮ +# │ file │ +# ╰──────╯ + +rwx_file_append() { + local file="${1}" + local text="${2}" + if [ -n "${file}" ]; then + printf "%s" "${text}" >>"${file}" + fi +} + +rwx_file_empty() { + local file="${1}" + if [ -n "${file}" ]; then + rwx_file_write "${file}" "" + fi +} + +rwx_file_write() { + local file="${1}" + local text="${2}" + if [ -n "${file}" ]; then + printf "%s" "${text}" >"${file}" + fi +} diff --git a/sh/main.sh b/sh/main.sh index 40fbf17..78c7677 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,5 +1,9 @@ #! /usr/bin/env sh +# ╭──────╮ +# │ main │ +# ╰──────╯ + # ╭──────┬───────────╮ # │ main │ constants │ # ╰──────┴───────────╯ @@ -127,12 +131,12 @@ rwx_source() { # run initial steps rwx_main() { - # system root + # source system root if ! rwx_source "${RWX_ROOT_SYSTEM}"; then __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" return 1 fi - # user root + # source user root rwx_source "${RWX_SELF_USER}" # context / command if [ -n "${RWX_COMMAND_NAME}" ]; then diff --git a/sh/tmux.sh b/sh/tmux.sh index 0294e7f..a29ec26 100644 --- a/sh/tmux.sh +++ b/sh/tmux.sh @@ -1,3 +1,7 @@ +# ╭──────╮ +# │ tmux │ +# ╰──────╯ + # ╭──────┬───────╮ # │ tmux │ setup │ # ╰──────┴───────╯ diff --git a/sh/util.sh b/sh/util.sh index cbcd67a..a3c53bf 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -1,25 +1,6 @@ -rwx_file_append() { - local file="${1}" - local text="${2}" - if [ -n "${file}" ]; then - printf "%s" "${text}" >>"${file}" - fi -} - -rwx_file_empty() { - local file="${1}" - if [ -n "${file}" ]; then - rwx_file_write "${file}" "" - fi -} - -rwx_file_write() { - local file="${1}" - local text="${2}" - if [ -n "${file}" ]; then - printf "%s" "${text}" >"${file}" - fi -} +# ╭──────╮ +# │ util │ +# ╰──────╯ rwx_link() { local link="${1}" From 2ad74cc9f79d05796c07ecfd97820cdb71e67cd5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 28 Jun 2025 04:40:19 +0200 Subject: [PATCH 2/7] main/log --- sh/main.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 78c7677..f7df12d 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -43,20 +43,6 @@ rwx_shell_interactive() { esac } -# ╭──────┬─────╮ -# │ main │ log │ -# ╰──────┴─────╯ - -__rwx_log() { - if rwx_shell_interactive; then - [ ${#} -gt 0 ] || set -- "" - local line - for line in "${@}"; do - echo "${line}" - done - fi -} - # ╭──────┬──────╮ # │ main │ find │ # ╰──────┴──────╯ @@ -101,6 +87,20 @@ rwx_ifs_unset() { unset RWX_IFS } +# ╭──────┬─────╮ +# │ main │ log │ +# ╰──────┴─────╯ + +__rwx_log() { + if rwx_shell_interactive; then + [ ${#} -gt 0 ] || set -- "" + local line + for line in "${@}"; do + echo "${line}" + done + fi +} + # ╭──────┬────────╮ # │ main │ source │ # ╰──────┴────────╯ @@ -125,9 +125,9 @@ rwx_source() { rwx_ifs_unset } -# ╭──────╮ -# │ main │ -# ╰──────╯ +# ╭──────┬──────╮ +# │ main │ main │ +# ╰──────┴──────╯ # run initial steps rwx_main() { From 3fbeb428354fba260cee2a9381f7e7012148857e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 28 Jun 2025 04:41:33 +0200 Subject: [PATCH 3/7] main/shell --- sh/main.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index f7df12d..3ddc530 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -31,18 +31,6 @@ RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" -# ╭──────┬───────╮ -# │ main │ shell │ -# ╰──────┴───────╯ - -# test if active shell is in interactive mode -rwx_shell_interactive() { - case "${-}" in - *i*) ;; - *) return 1 ;; - esac -} - # ╭──────┬──────╮ # │ main │ find │ # ╰──────┴──────╯ @@ -87,6 +75,18 @@ rwx_ifs_unset() { unset RWX_IFS } +# ╭──────┬───────╮ +# │ main │ shell │ +# ╰──────┴───────╯ + +# test if active shell is in interactive mode +rwx_shell_interactive() { + case "${-}" in + *i*) ;; + *) return 1 ;; + esac +} + # ╭──────┬─────╮ # │ main │ log │ # ╰──────┴─────╯ From 65e9e4b5f7f10ac7848f6906dee502ee782b8047 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 28 Jun 2025 04:45:29 +0200 Subject: [PATCH 4/7] main/run --- sh/main.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sh/main.sh b/sh/main.sh index 3ddc530..bdd7a93 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -147,5 +147,9 @@ rwx_main() { fi } +# ╭──────┬─────╮ +# │ main │ run │ +# ╰──────┴─────╯ + # run main function rwx_main "${@}" From bbb355ca709752ad0e128c421a2da79c3e6f08fe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 28 Jun 2025 04:50:53 +0200 Subject: [PATCH 5/7] =?UTF-8?q?=E2=86=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/main.sh | 162 ++++++++++++++++++++++++++--------------------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index bdd7a93..63ca6bf 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -32,72 +32,24 @@ RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" # ╭──────┬──────╮ -# │ main │ find │ +# │ main │ main │ # ╰──────┴──────╯ -# find directory’s files by extension -rwx_find_extension() { - local extension="${1}" - local root="${2}" - local file="${3}" - set -- \ - "${root}" \ - -name "*.${extension}" \ - -type "f" - [ -n "${file}" ] && - set -- "${@}" \ - -not \ - -name "${file}" - find "${@}" \ - -printf "%P\n" | - sort -} - -# find directory’s sh files -rwx_find_shell() { - rwx_find_extension "sh" "${@}" -} - -# ╭──────┬─────╮ -# │ main │ ifs │ -# ╰──────┴─────╯ - -# set internal field separator to line feed -rwx_ifs_set() { - _RWX_IFS="${IFS}" - IFS=" -" -} - -# unset internal field separator -rwx_ifs_unset() { - IFS="${_RWX_IFS}" - unset RWX_IFS -} - -# ╭──────┬───────╮ -# │ main │ shell │ -# ╰──────┴───────╯ - -# test if active shell is in interactive mode -rwx_shell_interactive() { - case "${-}" in - *i*) ;; - *) return 1 ;; - esac -} - -# ╭──────┬─────╮ -# │ main │ log │ -# ╰──────┴─────╯ - -__rwx_log() { - if rwx_shell_interactive; then - [ ${#} -gt 0 ] || set -- "" - local line - for line in "${@}"; do - echo "${line}" - done +# run initial steps +rwx_main() { + # source system root + if ! rwx_source "${RWX_ROOT_SYSTEM}"; then + __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" + return 1 + fi + # source user root + rwx_source "${RWX_SELF_USER}" + # context / command + if [ -n "${RWX_COMMAND_NAME}" ]; then + "${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}" + # context / shell + else + rwx_self_init fi } @@ -125,26 +77,74 @@ rwx_source() { rwx_ifs_unset } +# ╭──────┬─────╮ +# │ main │ log │ +# ╰──────┴─────╯ + +__rwx_log() { + if rwx_shell_interactive; then + [ ${#} -gt 0 ] || set -- "" + local line + for line in "${@}"; do + echo "${line}" + done + fi +} + +# ╭──────┬───────╮ +# │ main │ shell │ +# ╰──────┴───────╯ + +# test if active shell is in interactive mode +rwx_shell_interactive() { + case "${-}" in + *i*) ;; + *) return 1 ;; + esac +} + +# ╭──────┬─────╮ +# │ main │ ifs │ +# ╰──────┴─────╯ + +# set internal field separator to line feed +rwx_ifs_set() { + _RWX_IFS="${IFS}" + IFS=" +" +} + +# unset internal field separator +rwx_ifs_unset() { + IFS="${_RWX_IFS}" + unset RWX_IFS +} + # ╭──────┬──────╮ -# │ main │ main │ +# │ main │ find │ # ╰──────┴──────╯ -# run initial steps -rwx_main() { - # source system root - if ! rwx_source "${RWX_ROOT_SYSTEM}"; then - __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" - return 1 - fi - # source user root - rwx_source "${RWX_SELF_USER}" - # context / command - if [ -n "${RWX_COMMAND_NAME}" ]; then - "${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}" - # context / shell - else - rwx_self_init - fi +# find directory’s files by extension +rwx_find_extension() { + local extension="${1}" + local root="${2}" + local file="${3}" + set -- \ + "${root}" \ + -name "*.${extension}" \ + -type "f" + [ -n "${file}" ] && + set -- "${@}" \ + -not \ + -name "${file}" + find "${@}" \ + -printf "%P\n" | + sort +} + +# find directory’s sh files +rwx_find_shell() { + rwx_find_extension "sh" "${@}" } # ╭──────┬─────╮ From 5fcbfa35e9d1c7403852c79c12bdeb287d91500c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 28 Jun 2025 14:31:44 +0200 Subject: [PATCH 6/7] log --- sh/log/log.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sh/log/log.sh b/sh/log/log.sh index b921d45..a3013e8 100644 --- a/sh/log/log.sh +++ b/sh/log/log.sh @@ -1,3 +1,11 @@ +# ╭─────╮ +# │ log │ +# ╰─────╯ + +# ╭─────┬───────────╮ +# │ log │ constants │ +# ╰─────┴───────────╯ + RWX_LOG_LEVEL_FATAL=0 RWX_LOG_LEVEL_ERROR=1 RWX_LOG_LEVEL_WARN=2 @@ -5,8 +13,16 @@ RWX_LOG_LEVEL_INFO=3 RWX_LOG_LEVEL_DEBUG=4 RWX_LOG_LEVEL_TRACE=5 +# ╭─────┬───────────╮ +# │ log │ variables │ +# ╰─────┴───────────╯ + RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO} +# ╭─────┬─────╮ +# │ log │ log │ +# ╰─────┴─────╯ + rwx_log() { rwx_log_info "${@}"; } rwx_log_debug() { From f4d3d61cd7c501fc0ffd8a4bdea2ab52ae40c627 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 28 Jun 2025 15:43:06 +0200 Subject: [PATCH 7/7] git/compact --- sh/alias/git.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sh/alias/git.sh b/sh/alias/git.sh index fe5380a..35402d9 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -1,10 +1,8 @@ RWX_GIT_LOG_FORMAT="\ %C(auto)%h%d S %C(red)%GS -A %C(green)%an %ae - %C(green)%ai -C %C(blue)%cn %ce - %C(blue)%ci +A %C(green)%ai %an %ae +C %C(blue)%ci %cn %ce %B" # add to index