Compare commits

..

No commits in common. "f4d3d61cd7c501fc0ffd8a4bdea2ab52ae40c627" and "1cad82456e3d603915906ce676b59534dfa8cc32" have entirely different histories.

6 changed files with 95 additions and 128 deletions

View file

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

View file

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

View file

@ -1,9 +1,5 @@
#! /usr/bin/env sh
# ╭──────╮
# │ main │
# ╰──────╯
# ╭──────┬───────────╮
# │ main │ constants │
# ╰──────┴───────────╯
@ -31,50 +27,16 @@ RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}"
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
# ╭──────┬──────
# │ main │ main
# ╰──────┴──────
# ╭──────┬──────
# │ main │ shell
# ╰──────┴──────
# run initial steps
rwx_main() {
# source system root
if ! rwx_source "${RWX_ROOT_SYSTEM}"; then
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
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
# test if active shell is in interactive mode
rwx_shell_interactive() {
case "${-}" in
*i*) ;;
*) return 1 ;;
esac
}
# ╭──────┬─────╮
@ -91,35 +53,6 @@ __rwx_log() {
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 │
# ╰──────┴──────╯
@ -148,8 +81,67 @@ rwx_find_shell() {
}
# ╭──────┬─────╮
# │ main │ run
# │ 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 │ 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
rwx_main "${@}"

View file

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

View file

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