From 2b5fe88eeefef77114509dcb3c44964c963334f7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 09:47:16 +0200 Subject: [PATCH 01/22] close/useless --- sh/main.awk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sh/main.awk b/sh/main.awk index 2dca2cb..1476cf9 100644 --- a/sh/main.awk +++ b/sh/main.awk @@ -93,6 +93,8 @@ BEGIN { } else { reset() } + } else if (match($0, RE_CLOSE, m)) { + # TODO } else { if (module) { output(target, "module") From b6c962abde5160ab3d2f19bc00b5293819fe2cca Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 09:49:00 +0200 Subject: [PATCH 02/22] =?UTF-8?q?=E2=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/main.awk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/main.awk b/sh/main.awk index 1476cf9..d12e61d 100644 --- a/sh/main.awk +++ b/sh/main.awk @@ -6,7 +6,8 @@ function append(line) { } function output(name, type) { - print name " ← " type + print "↙ " type + print name print doc exit } From d0596131ca890bc76e8327cc2937ff251ab6c963 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 10:15:43 +0200 Subject: [PATCH 03/22] close/algorithm --- sh/main.awk | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sh/main.awk b/sh/main.awk index d12e61d..911a4c1 100644 --- a/sh/main.awk +++ b/sh/main.awk @@ -13,7 +13,9 @@ function output(name, type) { } function reset() { - doc = "" + if (f == "") { + doc = "" + } } BEGIN { @@ -38,6 +40,7 @@ BEGIN { RE_VARIABLE = RE_BEGIN RE_VAR RE_SET RE_END alias = 0 + f = "" reset() module = 0 } @@ -86,16 +89,17 @@ BEGIN { module = 1 } } else if (match($0, RE_FUNCTION, m)) { + f = m[1] + } else if (match($0, RE_CLOSE, m)) { if (alias) { print "= " target - output(m[1], "function") - } else if (m[1] == target) { - output(target, "function") + output(f, "function") + } else if (f == target) { + output(f, "function") } else { + f = "" reset() } - } else if (match($0, RE_CLOSE, m)) { - # TODO } else { if (module) { output(target, "module") From 030beb5ebe4e2e60332e0ee2adcdfd94bb654486 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 10:18:18 +0200 Subject: [PATCH 04/22] doc/spaces --- sh/main.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/main.awk b/sh/main.awk index 911a4c1..49fbce5 100644 --- a/sh/main.awk +++ b/sh/main.awk @@ -33,7 +33,7 @@ BEGIN { RE_ALIAS = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END RE_CONSTANT = RE_BEGIN RE_CONST RE_SET RE_END - RE_DOC = RE_BEGIN "#" RE_SPACE RE_ANY RE_END + RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END RE_FUNCTION = RE_BEGIN RE_VAR RE_FUNC RE_END RE_MODULE = RE_BEGIN "#." RE_SPACES RE_ANY RE_END RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END From 58a0ca7c16b5bcef1ae4f689cde2c6984259e159 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 10:20:52 +0200 Subject: [PATCH 05/22] f/comments --- sh/main.awk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sh/main.awk b/sh/main.awk index 49fbce5..d21bf86 100644 --- a/sh/main.awk +++ b/sh/main.awk @@ -63,7 +63,11 @@ BEGIN { if (match($0, RE_SHEBANG, m)) { append("! " m[1]) } else if (match($0, RE_DOC, m)) { - append(m[1]) + if (f) { + append($0) + } else { + append(m[1]) + } } else if (match($0, RE_ALIAS, m)) { append("= " m[1]) if (m[1] == target) { From 7c65fb2e25c491ebb15f65358a22e65d1f73dfd4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 10:30:24 +0200 Subject: [PATCH 06/22] rc,rcc,rd --- sh/self.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sh/self.sh b/sh/self.sh index 901c588..b406bfc 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -1,7 +1,20 @@ # self # module +# show the cached code +#= rc +rwx_code() { + echo "${_rwx_code}" +} + +# show the cached constants +#= rcc +rwx_code_constants() { + echo "${RWX_CONSTANTS}" +} + # meta doc +#= rd rwx_doc() { local name="${1}" [ -n "${name}" ] || return From 1d6a7bab9b0f4c9a9c4d73a6d109b0d1ce08f7d9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 11:02:50 +0200 Subject: [PATCH 07/22] cache/variables --- sh/main.sh | 21 +++++++++++++++++---- sh/self.sh | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index d26159a..72ebd54 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -172,17 +172,23 @@ RWX_REGEX_CONSTANT="[_A-Z][_0-9A-Z]*" RWX_REGEX_FUNCTION="[_A-Za-z][_0-9A-Za-z]*" RWX_REGEX_SET="=.*" RWX_REGEX_SPACES="[[:space:]]*" +RWX_REGEX_VARIABLE="[_a-z][_0-9a-z]*" -RWX_REGEX_BEGIN="^${RWX_REGEX_SPACES}" +RWX_REGEX_BEGIN="^" RWX_REGEX_OPEN="\ ${RWX_REGEX_SPACES}(${RWX_REGEX_SPACES})${RWX_REGEX_SPACES}{.*" RWX_REGEX_TARGET_CONSTANT="\ ${RWX_REGEX_BEGIN}\\(${RWX_REGEX_CONSTANT}\\)${RWX_REGEX_SET}" RWX_REGEX_TARGET_DOC="\ -${RWX_REGEX_BEGIN}# \\(.*\\)${RWX_REGEX_SPACES}\$" +${RWX_REGEX_BEGIN}${RWX_REGEX_SPACES}# \\(.*\\)${RWX_REGEX_SPACES}\$" RWX_REGEX_TARGET_FUNCTION="\ ${RWX_REGEX_BEGIN}\\(${RWX_REGEX_FUNCTION}\\)${RWX_REGEX_OPEN}" +RWX_REGEX_TARGET_VARIABLE="\ +${RWX_REGEX_BEGIN}\\(${RWX_REGEX_VARIABLE}\\)${RWX_REGEX_SET}" + +# cache for code variables +_rwx_code_variables="" rwx_parse_code() { # parse aliases @@ -197,6 +203,8 @@ EOF RWX_CONSTANTS="$(rwx_parse_constants)" # parse functions RWX_FUNCTIONS="$(rwx_parse_functions)" + # parse variables + _rwx_code_variables="$(rwx_parse_variables)" } rwx_parse_aliases() { printf "%s" "${_rwx_code}" | @@ -205,18 +213,23 @@ rwx_parse_aliases() { --file "${RWX_AWK}" } rwx_parse_constants() { - printf "%s\n" "${_rwx_code}" | + printf "%s" "${_rwx_code}" | sed --silent "s|${RWX_REGEX_TARGET_CONSTANT}|\\1|p" } rwx_parse_functions() { - printf "%s\n" "${_rwx_code}" | + printf "%s" "${_rwx_code}" | sed --silent "s|${RWX_REGEX_TARGET_FUNCTION}|\\1|p" } +rwx_parse_variables() { + printf "%s" "${_rwx_code}" | + sed --silent "s|${RWX_REGEX_TARGET_VARIABLE}|\\1|p" +} # ╭──────┬──────╮ # │ main │ test │ # ╰──────┴──────╯ +#= rt rwx_test() { local item # TODO CODE diff --git a/sh/self.sh b/sh/self.sh index b406bfc..e2c30f7 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -7,12 +7,30 @@ rwx_code() { echo "${_rwx_code}" } +# show the cached aliases +#= rca +rwx_code_aliases() { + echo "${RWX_ALIASES}" +} + # show the cached constants #= rcc rwx_code_constants() { echo "${RWX_CONSTANTS}" } +# show the cached functions +#= rcf +rwx_code_functions() { + echo "${RWX_FUNCTIONS}" +} + +# show the cached variables +#= rcv +rwx_code_variables() { + echo "${_rwx_code_variables}" +} + # meta doc #= rd rwx_doc() { From 513d09f797a5767c19911bd192839d68b0b7f900 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 15:32:43 +0200 Subject: [PATCH 08/22] gpg/gak,gau --- sh/alias/gpg.sh | 12 ------------ sh/gpg.sh | 10 ++++++++++ 2 files changed, 10 insertions(+), 12 deletions(-) delete mode 100644 sh/alias/gpg.sh diff --git a/sh/alias/gpg.sh b/sh/alias/gpg.sh deleted file mode 100644 index eb19651..0000000 --- a/sh/alias/gpg.sh +++ /dev/null @@ -1,12 +0,0 @@ -# turn gpg agent off -gak() { a__gpg_agent_kill "${@}"; } -a__gpg_agent_kill() { - gpgconf \ - --kill "gpg-agent" -} - -# bind gpg agent to current tty -gau() { a__gpg_agent_update "${@}"; } -a__gpg_agent_update() { - rwx_gpg_agent_update -} diff --git a/sh/gpg.sh b/sh/gpg.sh index b5ce07b..e1bf31c 100644 --- a/sh/gpg.sh +++ b/sh/gpg.sh @@ -1,4 +1,14 @@ +# functions to handle gpg + +# turn gpg agent off +#= gak +rwx_gpg_agent_kill() { + gpgconf \ + --kill "gpg-agent" +} + # bind gpg agent to current tty +#= gau rwx_gpg_agent_update() { gpg-connect-agent \ updatestartuptty \ From 9910ad39429cac17b7febef6b1960376ca66c4a3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 15:36:05 +0200 Subject: [PATCH 09/22] b --- sh/alias/batcat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/alias/batcat.sh b/sh/alias/batcat.sh index 99d8373..c573adb 100644 --- a/sh/alias/batcat.sh +++ b/sh/alias/batcat.sh @@ -1,4 +1,4 @@ -b() { a__bat "${@}"; } +#= b a__bat() { batcat \ "${@}" From 20bc9fc4fb9522b0ab426710c6640125fa368416 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 15:38:06 +0200 Subject: [PATCH 10/22] b --- sh/main.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 72ebd54..cb457b6 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -246,7 +246,8 @@ rwx_test() { \ "rwx_cache" \ \ - "gsc" + "alias/batcat" \ + "b" for item in "${@}"; do echo rwx_doc "${item}" From 715a13e871694ae796ff25b2dff0ad48bf3b8081 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 15:53:19 +0200 Subject: [PATCH 11/22] =?UTF-8?q?=E2=88=92todo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/main.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index cb457b6..f51b918 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -232,10 +232,6 @@ rwx_parse_variables() { #= rt rwx_test() { local item - # TODO CODE - # TODO CONSTANTS - # TODO functions - # TODO variables set \ "main" \ "alias/git" \ From c21cbb1e98dab897381ee5a64c2102e93d23062a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 15:57:42 +0200 Subject: [PATCH 12/22] tabs --- sh/main.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index f51b918..a1ac540 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -231,23 +231,23 @@ rwx_parse_variables() { #= rt rwx_test() { - local item - set \ - "main" \ - "alias/git" \ - \ - "RWX_MAIN_NAME" \ - \ - "_rwx_code" \ - \ - "rwx_cache" \ - \ - "alias/batcat" \ - "b" - for item in "${@}"; do - echo - rwx_doc "${item}" - done + local item + set \ + "main" \ + "alias/git" \ + \ + "RWX_MAIN_NAME" \ + \ + "_rwx_code" \ + \ + "rwx_cache" \ + \ + "alias/batcat" \ + "b" + for item in "${@}"; do + echo + rwx_doc "${item}" + done } # ╭──────┬─────╮ From 69e71ee1a3c36499938426a81e26671af95a2d0c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 15:59:31 +0200 Subject: [PATCH 13/22] -n --- sh/tmux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/tmux.sh b/sh/tmux.sh index 85a616f..00ef126 100644 --- a/sh/tmux.sh +++ b/sh/tmux.sh @@ -6,7 +6,7 @@ #= tma rwx_tmux_attach() { local server="${1}" - if [ "${server}" ]; then + if [ -n "${server}" ]; then tmux -L "${server}" attach-session else rwx_tmux_list @@ -17,7 +17,7 @@ rwx_tmux_attach() { #= tmk rwx_tmux_kill() { local server="${1}" - if [ "${server}" ]; then + if [ -n "${server}" ]; then tmux -L "${server}" kill-server 2>"/dev/null" else rwx_tmux_list From 4b55ac115539596c894b56fa18ffe6b2fd9ff340 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 16:02:10 +0200 Subject: [PATCH 14/22] tabs --- sh/self.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sh/self.sh b/sh/self.sh index e2c30f7..8d821dc 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -4,31 +4,31 @@ # show the cached code #= rc rwx_code() { - echo "${_rwx_code}" + echo "${_rwx_code}" } # show the cached aliases #= rca rwx_code_aliases() { - echo "${RWX_ALIASES}" + echo "${RWX_ALIASES}" } # show the cached constants #= rcc rwx_code_constants() { - echo "${RWX_CONSTANTS}" + echo "${RWX_CONSTANTS}" } # show the cached functions #= rcf rwx_code_functions() { - echo "${RWX_FUNCTIONS}" + echo "${RWX_FUNCTIONS}" } # show the cached variables #= rcv rwx_code_variables() { - echo "${_rwx_code_variables}" + echo "${_rwx_code_variables}" } # meta doc From de0dd93a718995134bf4d89f47355d3122b79d1c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 16:03:46 +0200 Subject: [PATCH 15/22] lint/files --- sh/self.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/self.sh b/sh/self.sh index 8d821dc..4d88414 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -222,10 +222,10 @@ rwx_self_write() { local target="${1}" if [ -n "${target}" ]; then shift - local file text + local file files text text="#! /usr/bin/env sh " - local files="$(rwx_self_subset "${@}")" + files="$(rwx_self_subset "${@}")" while IFS= read -r file; do text="${text} $(cat "${RWX_ROOT_SYSTEM}/${file}") From 249aa0b19c92a005461d0744b122c570e1c8963b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 16:05:10 +0200 Subject: [PATCH 16/22] lint/modules --- sh/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index a1ac540..75b1815 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -94,11 +94,11 @@ rwx_source() { [ -d "${root}" ] || return 1 local file="${2}" - local count module + local count module modules count=0 __rwx_log "" \ ". ${root}" - local modules="$(rwx_find_shell "${root}" "${file}")" + modules="$(rwx_find_shell "${root}" "${file}")" while IFS= read -r module; do count=$((count + 1)) __rwx_log "$(printf "%02d" "${count}") ${module%.sh}" From 5c5464d4ae8b41e8a519dd5c147946f9f9c371a1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 16:09:46 +0200 Subject: [PATCH 17/22] lint/uid --- sh/tmux.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sh/tmux.sh b/sh/tmux.sh index 00ef126..9213e01 100644 --- a/sh/tmux.sh +++ b/sh/tmux.sh @@ -27,7 +27,9 @@ rwx_tmux_kill() { # list #= tml rwx_tmux_list() { - ls "/tmp/tmux-$(id --user)" + local user_id + user_id="$(id --user)" + ls "/tmp/tmux-${user_id}" } # ╭──────┬───────╮ From c4b63c5de63eca928a5dd29225840afd75298db7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 6 Jul 2025 16:39:35 +0200 Subject: [PATCH 18/22] eval --- sh/main.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 75b1815..94908be 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -192,10 +192,13 @@ _rwx_code_variables="" rwx_parse_code() { # parse aliases - local line + local line text RWX_ALIASES="$(rwx_parse_aliases)" while IFS= read -r line; do - eval "${line/ = /() { } \"\${@}\"; }" + text="s| = |() { |" + text="$(echo "${line}" | sed "${text}")" + text="${text} \"\${@}\"; }" + eval "${text}" done < Date: Sun, 6 Jul 2025 16:41:01 +0200 Subject: [PATCH 19/22] eval/shrink --- sh/main.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 94908be..66751c7 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -196,9 +196,7 @@ rwx_parse_code() { RWX_ALIASES="$(rwx_parse_aliases)" while IFS= read -r line; do text="s| = |() { |" - text="$(echo "${line}" | sed "${text}")" - text="${text} \"\${@}\"; }" - eval "${text}" + eval "$(echo "${line}" | sed "${text}") \"\${@}\"; }" done < Date: Sun, 6 Jul 2025 16:42:12 +0200 Subject: [PATCH 20/22] eval/oneline --- sh/main.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 66751c7..0abfb5e 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -195,8 +195,7 @@ rwx_parse_code() { local line text RWX_ALIASES="$(rwx_parse_aliases)" while IFS= read -r line; do - text="s| = |() { |" - eval "$(echo "${line}" | sed "${text}") \"\${@}\"; }" + eval "$(echo "${line}" | sed "s| = |() { |") \"\${@}\"; }" done < Date: Sun, 6 Jul 2025 16:44:31 +0200 Subject: [PATCH 21/22] eval/lint --- sh/main.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 0abfb5e..ae806a3 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -195,7 +195,9 @@ rwx_parse_code() { local line text RWX_ALIASES="$(rwx_parse_aliases)" while IFS= read -r line; do - eval "$(echo "${line}" | sed "s| = |() { |") \"\${@}\"; }" + text="$(echo "${line}" | sed "s| = |() { |")" + text="${text} \"\${@}\"; }" + eval "${text}" done < Date: Sun, 6 Jul 2025 16:47:30 +0200 Subject: [PATCH 22/22] =?UTF-8?q?=E2=88=92=3D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/main.awk | 2 +- sh/main.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.awk b/sh/main.awk index d21bf86..b8a8f59 100644 --- a/sh/main.awk +++ b/sh/main.awk @@ -52,7 +52,7 @@ BEGIN { } else if (match($0, RE_FUNCTION, m)) { n = split(doc, array, "\n") for (i = 1; i<= n; i++) { - print array[i] " = " m[1] + print array[i] " " m[1] } reset() } else { diff --git a/sh/main.sh b/sh/main.sh index ae806a3..838b028 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -195,7 +195,7 @@ rwx_parse_code() { local line text RWX_ALIASES="$(rwx_parse_aliases)" while IFS= read -r line; do - text="$(echo "${line}" | sed "s| = |() { |")" + text="$(echo "${line}" | sed "s| |() { |")" text="${text} \"\${@}\"; }" eval "${text}" done <