diff --git a/sh/alias/shell.sh b/sh/alias/shell.sh new file mode 100644 index 0000000..f216c92 --- /dev/null +++ b/sh/alias/shell.sh @@ -0,0 +1,18 @@ +# shorten alias +a() { + alias \ + "${@}" +} + +# swap directory (current ↔ previous) +sd() { + cd \ + - || + return +} + +# exit terminal +x() { + exit \ + "${@}" +} diff --git a/sh/main.sh b/sh/main.sh index 16ce907..470cf72 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -26,6 +26,9 @@ 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/0.sh similarity index 79% rename from sh/shell.sh rename to sh/shell/0.sh index 8400fd2..6a28c31 100644 --- a/sh/shell.sh +++ b/sh/shell/0.sh @@ -35,13 +35,6 @@ 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 │ # ╰───────┴───────────╯ @@ -80,7 +73,6 @@ rwx_shell_configure() { *) ;; esac } -rwx_shell_configure rwx_shell_prompt() { local date host id @@ -135,36 +127,12 @@ rwx_shell_prompt() { printf "%b" "${view}" } -# ╭───────┬───────────╮ -# │ shell │ shortcuts │ -# ╰───────┴───────────╯ +# ╭───────┬──────╮ +# │ shell │ main │ +# ╰───────┴──────╯ -# shorten alias -a() { - alias \ - "${@}" +rwx_shell_main() { + rwx_shell_configure } -# swap directory (current ↔ previous) -sd() { - cd \ - - || - return -} - -# exit terminal -x() { - exit \ - "${@}" -} - -[ "${RWX_SHELL}" = "bash" ] || return - -# shellcheck disable=SC3033 -..() { - cd .. -} -# shellcheck disable=SC3033 -...() { - cd ../.. -} +rwx_shell_main diff --git a/sh/shell/bash.sh b/sh/shell/bash.sh new file mode 100644 index 0000000..400f83c --- /dev/null +++ b/sh/shell/bash.sh @@ -0,0 +1,24 @@ +# ╭───────┬──────╮ +# │ shell │ bash │ +# ╰───────┴──────╯ + +if [ "${RWX_SHELL}" = "bash" ]; then + +# shellcheck disable=SC3033 +..() { + cd .. +} +# shellcheck disable=SC3033 +...() { + cd ../.. +} +# shellcheck disable=SC3033 +....() { + cd ../../.. +} +# shellcheck disable=SC3033 +.....() { + cd ../../../.. +} + +fi