From dd90da8a821281794e30fd82d1600e93723f29e7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 7 Jul 2025 05:48:43 +0200 Subject: [PATCH 1/5] shell/standalone --- sh/alias/shell.sh | 29 ------------------------- sh/main.sh | 3 --- sh/shell.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 32 deletions(-) delete mode 100644 sh/alias/shell.sh diff --git a/sh/alias/shell.sh b/sh/alias/shell.sh deleted file mode 100644 index d6f5801..0000000 --- a/sh/alias/shell.sh +++ /dev/null @@ -1,29 +0,0 @@ -# shorten alias -a() { - alias \ - "${@}" -} - -# swap directory (current ↔ previous) -sd() { - cd \ - - || - return -} - -# exit terminal -x() { - exit \ - "${@}" -} - -[ "${RWX_SHELL}" = "bash" ] || return - -# shellcheck disable=SC3033 -..() { - cd .. -} -# shellcheck disable=SC3033 -...() { - cd ../.. -} diff --git a/sh/main.sh b/sh/main.sh index 470cf72..16ce907 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -26,9 +26,6 @@ RWX_SELF_NAME="rwx" # │ main │ variables │ # ╰──────┴───────────╯ -# currently running shell name -RWX_SHELL="$(cat "/proc/${$}/comm")" - # system root directory of the project RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" # user root directory of the project diff --git a/sh/shell.sh b/sh/shell.sh index 7e56658..8400fd2 100644 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -1,3 +1,7 @@ +# ╭───────╮ +# │ shell │ +# ╰───────╯ + _rwx_shell_color() { local code="${1}" case "${RWX_SHELL}" in @@ -19,6 +23,11 @@ _rwx_shell_color() { ;; esac } + +# ╭───────┬───────────╮ +# │ shell │ constants │ +# ╰───────┴───────────╯ + RWX_COLOR_BROWN="$(_rwx_shell_color 33)" RWX_COLOR_CYAN="$(_rwx_shell_color 36)" RWX_COLOR_DEFAULT="$(_rwx_shell_color)" @@ -26,6 +35,17 @@ RWX_COLOR_GREEN="$(_rwx_shell_color 31)" RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)" RWX_COLOR_RED="$(_rwx_shell_color 32)" +# ╭───────┬───────────╮ +# │ shell │ variables │ +# ╰───────┴───────────╯ + +# currently running shell name +RWX_SHELL="$(cat "/proc/${$}/comm")" + +# ╭───────┬───────────╮ +# │ shell │ functions │ +# ╰───────┴───────────╯ + rwx_shell_configure() { [ -n "${ENV}" ] || ENV="${RWX_MAIN_PATH}" export ENV @@ -114,3 +134,37 @@ rwx_shell_prompt() { # print printf "%b" "${view}" } + +# ╭───────┬───────────╮ +# │ shell │ shortcuts │ +# ╰───────┴───────────╯ + +# shorten alias +a() { + alias \ + "${@}" +} + +# swap directory (current ↔ previous) +sd() { + cd \ + - || + return +} + +# exit terminal +x() { + exit \ + "${@}" +} + +[ "${RWX_SHELL}" = "bash" ] || return + +# shellcheck disable=SC3033 +..() { + cd .. +} +# shellcheck disable=SC3033 +...() { + cd ../.. +} From a06bab3e976089aa283f9c1214f178ccaf369009 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 7 Jul 2025 21:38:07 +0200 Subject: [PATCH 2/5] shell/bash --- sh/alias/shell.sh | 11 ----------- sh/shell/bash.sh | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 sh/shell/bash.sh diff --git a/sh/alias/shell.sh b/sh/alias/shell.sh index d6f5801..f216c92 100644 --- a/sh/alias/shell.sh +++ b/sh/alias/shell.sh @@ -16,14 +16,3 @@ x() { exit \ "${@}" } - -[ "${RWX_SHELL}" = "bash" ] || return - -# shellcheck disable=SC3033 -..() { - cd .. -} -# shellcheck disable=SC3033 -...() { - cd ../.. -} diff --git a/sh/shell/bash.sh b/sh/shell/bash.sh new file mode 100644 index 0000000..627079b --- /dev/null +++ b/sh/shell/bash.sh @@ -0,0 +1,18 @@ +[ "${RWX_SHELL}" = "bash" ] || return + +# shellcheck disable=SC3033 +..() { + cd .. +} +# shellcheck disable=SC3033 +...() { + cd ../.. +} +# shellcheck disable=SC3033 +....() { + cd ../../.. +} +# shellcheck disable=SC3033 +.....() { + cd ../../../.. +} From ff5116380c7ac73a658ffd20b75639b46528a570 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 7 Jul 2025 21:43:48 +0200 Subject: [PATCH 3/5] bash/if --- sh/shell/bash.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sh/shell/bash.sh b/sh/shell/bash.sh index 627079b..400f83c 100644 --- a/sh/shell/bash.sh +++ b/sh/shell/bash.sh @@ -1,4 +1,8 @@ -[ "${RWX_SHELL}" = "bash" ] || return +# ╭───────┬──────╮ +# │ shell │ bash │ +# ╰───────┴──────╯ + +if [ "${RWX_SHELL}" = "bash" ]; then # shellcheck disable=SC3033 ..() { @@ -16,3 +20,5 @@ .....() { cd ../../../.. } + +fi From efe07205fa95376a26f16df3a78ab639aa42e0bc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 7 Jul 2025 21:50:34 +0200 Subject: [PATCH 4/5] shell/0 --- sh/{shell.sh => shell/0.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{shell.sh => shell/0.sh} (100%) diff --git a/sh/shell.sh b/sh/shell/0.sh similarity index 100% rename from sh/shell.sh rename to sh/shell/0.sh From aec3d1a0afe49b5065e75040e2be11aec7076876 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 7 Jul 2025 21:55:01 +0200 Subject: [PATCH 5/5] shell/main --- sh/shell/0.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sh/shell/0.sh b/sh/shell/0.sh index 7e56658..6a28c31 100644 --- a/sh/shell/0.sh +++ b/sh/shell/0.sh @@ -1,3 +1,7 @@ +# ╭───────╮ +# │ shell │ +# ╰───────╯ + _rwx_shell_color() { local code="${1}" case "${RWX_SHELL}" in @@ -19,6 +23,11 @@ _rwx_shell_color() { ;; esac } + +# ╭───────┬───────────╮ +# │ shell │ constants │ +# ╰───────┴───────────╯ + RWX_COLOR_BROWN="$(_rwx_shell_color 33)" RWX_COLOR_CYAN="$(_rwx_shell_color 36)" RWX_COLOR_DEFAULT="$(_rwx_shell_color)" @@ -26,6 +35,10 @@ RWX_COLOR_GREEN="$(_rwx_shell_color 31)" RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)" RWX_COLOR_RED="$(_rwx_shell_color 32)" +# ╭───────┬───────────╮ +# │ shell │ functions │ +# ╰───────┴───────────╯ + rwx_shell_configure() { [ -n "${ENV}" ] || ENV="${RWX_MAIN_PATH}" export ENV @@ -60,7 +73,6 @@ rwx_shell_configure() { *) ;; esac } -rwx_shell_configure rwx_shell_prompt() { local date host id @@ -114,3 +126,13 @@ rwx_shell_prompt() { # print printf "%b" "${view}" } + +# ╭───────┬──────╮ +# │ shell │ main │ +# ╰───────┴──────╯ + +rwx_shell_main() { + rwx_shell_configure +} + +rwx_shell_main