Compare commits

..

7 commits

Author SHA1 Message Date
f4d3d61cd7
git/compact
All checks were successful
/ job (push) Successful in 5m0s
2025-06-28 15:43:06 +02:00
5fcbfa35e9
log 2025-06-28 14:31:44 +02:00
bbb355ca70
2025-06-28 04:50:53 +02:00
65e9e4b5f7
main/run 2025-06-28 04:45:29 +02:00
3fbeb42835
main/shell 2025-06-28 04:41:33 +02:00
2ad74cc9f7
main/log 2025-06-28 04:40:19 +02:00
88f3ab499d
file 2025-06-28 04:36:16 +02:00
6 changed files with 128 additions and 95 deletions

View file

@ -1,10 +1,8 @@
RWX_GIT_LOG_FORMAT="\ RWX_GIT_LOG_FORMAT="\
%C(auto)%h%d %C(auto)%h%d
S %C(red)%GS S %C(red)%GS
A %C(green)%an %ae A %C(green)%ai %an %ae
%C(green)%ai C %C(blue)%ci %cn %ce
C %C(blue)%cn %ce
%C(blue)%ci
%B" %B"
# add to index # add to index

26
sh/file.sh Normal file
View file

@ -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
}

View file

@ -1,3 +1,11 @@
# ╭─────╮
# │ log │
# ╰─────╯
# ╭─────┬───────────╮
# │ log │ constants │
# ╰─────┴───────────╯
RWX_LOG_LEVEL_FATAL=0 RWX_LOG_LEVEL_FATAL=0
RWX_LOG_LEVEL_ERROR=1 RWX_LOG_LEVEL_ERROR=1
RWX_LOG_LEVEL_WARN=2 RWX_LOG_LEVEL_WARN=2
@ -5,8 +13,16 @@ RWX_LOG_LEVEL_INFO=3
RWX_LOG_LEVEL_DEBUG=4 RWX_LOG_LEVEL_DEBUG=4
RWX_LOG_LEVEL_TRACE=5 RWX_LOG_LEVEL_TRACE=5
# ╭─────┬───────────╮
# │ log │ variables │
# ╰─────┴───────────╯
RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO} RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO}
# ╭─────┬─────╮
# │ log │ log │
# ╰─────┴─────╯
rwx_log() { rwx_log_info "${@}"; } rwx_log() { rwx_log_info "${@}"; }
rwx_log_debug() { rwx_log_debug() {

View file

@ -1,5 +1,9 @@
#! /usr/bin/env sh #! /usr/bin/env sh
# ╭──────╮
# │ main │
# ╰──────╯
# ╭──────┬───────────╮ # ╭──────┬───────────╮
# │ main │ constants │ # │ main │ constants │
# ╰──────┴───────────╯ # ╰──────┴───────────╯
@ -27,16 +31,50 @@ RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}"
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
# ╭──────┬────── # ╭──────┬──────
# │ main │ shell # │ main │ main
# ╰──────┴────── # ╰──────┴──────
# test if active shell is in interactive mode # run initial steps
rwx_shell_interactive() { rwx_main() {
case "${-}" in # source system root
*i*) ;; if ! rwx_source "${RWX_ROOT_SYSTEM}"; then
*) return 1 ;; __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
esac 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
}
# ╭──────┬────────╮
# │ main │ source │
# ╰──────┴────────╯
# source code from file path
rwx_source() {
local path="${1}"
[ -d "${path}" ] ||
return 1
local count module
count=0
__rwx_log "" \
". ${path}"
rwx_ifs_set
for module in $(rwx_find_shell "${path}" "${RWX_MAIN_NAME}"); do
count=$((count + 1))
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
module="${path}/${module}"
# shellcheck disable=SC1090
. "${module}"
done
rwx_ifs_unset
} }
# ╭──────┬─────╮ # ╭──────┬─────╮
@ -53,6 +91,35 @@ __rwx_log() {
fi 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 │ find │ # │ main │ find │
# ╰──────┴──────╯ # ╰──────┴──────╯
@ -81,67 +148,8 @@ rwx_find_shell() {
} }
# ╭──────┬─────╮ # ╭──────┬─────╮
# │ main │ ifs # │ main │ run
# ╰──────┴─────╯ # ╰──────┴─────╯
# 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 │ source │
# ╰──────┴────────╯
# source code from file path
rwx_source() {
local path="${1}"
[ -d "${path}" ] ||
return 1
local count module
count=0
__rwx_log "" \
". ${path}"
rwx_ifs_set
for module in $(rwx_find_shell "${path}" "${RWX_MAIN_NAME}"); do
count=$((count + 1))
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
module="${path}/${module}"
# shellcheck disable=SC1090
. "${module}"
done
rwx_ifs_unset
}
# ╭──────╮
# │ main │
# ╰──────╯
# run initial steps
rwx_main() {
# system root
if ! rwx_source "${RWX_ROOT_SYSTEM}"; then
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
return 1
fi
# 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
}
# run main function # run main function
rwx_main "${@}" rwx_main "${@}"

View file

@ -1,3 +1,7 @@
# ╭──────╮
# │ tmux │
# ╰──────╯
# ╭──────┬───────╮ # ╭──────┬───────╮
# │ tmux │ setup │ # │ tmux │ setup │
# ╰──────┴───────╯ # ╰──────┴───────╯

View file

@ -1,25 +1,6 @@
rwx_file_append() { # ╭──────╮
local file="${1}" # │ util │
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
}
rwx_link() { rwx_link() {
local link="${1}" local link="${1}"