Compare commits
No commits in common. "dd90da8a821281794e30fd82d1600e93723f29e7" and "62b3a9264b150f7040d5b53690d4acf349b840b9" have entirely different histories.
dd90da8a82
...
62b3a9264b
3 changed files with 42 additions and 65 deletions
29
sh/alias/shell.sh
Normal file
29
sh/alias/shell.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
# 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 ../..
|
||||
}
|
24
sh/main.sh
24
sh/main.sh
|
@ -26,6 +26,17 @@ RWX_SELF_NAME="rwx"
|
|||
# │ main │ variables │
|
||||
# ╰──────┴───────────╯
|
||||
|
||||
RWX_COMMAND_ARGUMENT="${0}"
|
||||
# currently running shell name
|
||||
RWX_SHELL="$(cat "/proc/${$}/comm")"
|
||||
|
||||
# command name used to run
|
||||
# (stripped from hyphen interactive flag)
|
||||
RWX_COMMAND_NAME="$(basename "${RWX_COMMAND_ARGUMENT}" | sed "s|^-||")"
|
||||
case "${RWX_COMMAND_NAME}" in
|
||||
"bash" | "dash" | "sh") unset RWX_COMMAND_NAME ;;
|
||||
*) ;;
|
||||
esac
|
||||
# system root directory of the project
|
||||
RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}"
|
||||
# user root directory of the project
|
||||
|
@ -52,18 +63,9 @@ rwx_main() {
|
|||
# load code cache
|
||||
rwx_code_load
|
||||
# context / command
|
||||
local command
|
||||
# command name used to run
|
||||
# (stripped from hyphen interactive flag)
|
||||
command="$(basename "${0}" | sed "s|^-||")"
|
||||
case "${command}" in
|
||||
"bash" | "dash" | "sh") unset command ;;
|
||||
*) ;;
|
||||
esac
|
||||
if [ -n "${command}" ]; then
|
||||
if [ -n "${RWX_COMMAND_NAME}" ]; then
|
||||
local function
|
||||
# find the matching function
|
||||
function="$(rwx_code_alias_function "${command}")"
|
||||
function="$(rwx_code_alias_function "${RWX_COMMAND_NAME}")"
|
||||
if [ -n "${function}" ]; then
|
||||
"${function}" "${@}"
|
||||
fi
|
||||
|
|
54
sh/shell.sh
54
sh/shell.sh
|
@ -1,7 +1,3 @@
|
|||
# ╭───────╮
|
||||
# │ shell │
|
||||
# ╰───────╯
|
||||
|
||||
_rwx_shell_color() {
|
||||
local code="${1}"
|
||||
case "${RWX_SHELL}" in
|
||||
|
@ -23,11 +19,6 @@ _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)"
|
||||
|
@ -35,17 +26,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 │
|
||||
# ╰───────┴───────────╯
|
||||
|
||||
rwx_shell_configure() {
|
||||
[ -n "${ENV}" ] || ENV="${RWX_MAIN_PATH}"
|
||||
export ENV
|
||||
|
@ -134,37 +114,3 @@ 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 ../..
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue