Compare commits

..

No commits in common. "333da5fb6a4f1de4eb2f57d8f5be26d6f96f57b0" and "0e9108999d02f682b0342d5735d9f9d49985aa78" have entirely different histories.

5 changed files with 32 additions and 31 deletions

View file

@ -6,15 +6,16 @@
# │ code │ variables │ # │ code │ variables │
# ╰──────┴───────────╯ # ╰──────┴───────────╯
# TODO variablize
# path to the entrypoint main file of the project # path to the entrypoint main file of the project
rwx_code_main="${rwx_main_root}/${RWX_MAIN_MODULE}.${RWX_MAIN_EXTENSION}" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}.${RWX_MAIN_EXTENSION}"
# user root directory of the project # user root directory of the project
rwx_code_root="${HOME}/${RWX_MAIN_NAME}" RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}"
# cache of all sourced code modules # cache of all sourced code modules
_rwx_code="" _rwx_code=""
# cache for the parsing awk script # cache for the parsing awk script
_rwx_code_awk="$(cat "${rwx_main_root}/core/code.awk")" _rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/core/code.awk")"
# cache for code aliases # cache for code aliases
_rwx_code_aliases="" _rwx_code_aliases=""
# cache for code aliases functions # cache for code aliases functions
@ -54,16 +55,16 @@ rwx_code_install() {
local command file name root local command file name root
# code # code
if [ -n "${target}" ]; then if [ -n "${target}" ]; then
root="${target}${rwx_main_root}" root="${target}${RWX_ROOT_SYSTEM}"
rwx_remove "${root}" rwx_remove "${root}"
cp --recursive "${rwx_main_root}" "${root}" cp --recursive "${RWX_ROOT_SYSTEM}" "${root}"
fi fi
# commands # commands
root="${target}/usr/local/bin" root="${target}/usr/local/bin"
name="${RWX_MAIN_NAME}.${RWX_MAIN_EXTENSION}" name="${RWX_SELF_NAME}.${RWX_MAIN_EXTENSION}"
file="${root}/${name}" file="${root}/${name}"
rwx_remove "${file}" rwx_remove "${file}"
rwx_link "${file}" "${rwx_code_main}" rwx_link "${file}" "${RWX_MAIN_PATH}"
while IFS= read -r command; do while IFS= read -r command; do
file="${root}/${command}" file="${root}/${command}"
rwx_remove "${file}" rwx_remove "${file}"
@ -72,15 +73,15 @@ rwx_code_install() {
${_rwx_code_commands} ${_rwx_code_commands}
EOF EOF
# sh # sh
file="${target}/etc/profile.d/${RWX_MAIN_NAME}.${RWX_MAIN_EXTENSION}" file="${target}/etc/profile.d/${RWX_SELF_NAME}.${RWX_MAIN_EXTENSION}"
rwx_remove "${file}" rwx_remove "${file}"
rwx_file_write "${file}" "\ rwx_file_write "${file}" "\
export ENV=\"${rwx_code_main}\" export ENV=\"${RWX_MAIN_PATH}\"
" "
# bash # bash
file="${target}/etc/bash.bashrc" file="${target}/etc/bash.bashrc"
rwx_remove "${file}" rwx_remove "${file}"
rwx_link "${file}" "${rwx_code_main}" rwx_link "${file}" "${RWX_MAIN_PATH}"
} }
# ╭──────┬───────╮ # ╭──────┬───────╮
@ -163,10 +164,10 @@ rwx_code_variables() {
rwx_code_check() { rwx_code_check() {
# check format # check format
rwx_log rwx_log
rwx_shfmt "${rwx_main_root}" rwx_shfmt "${RWX_ROOT_SYSTEM}"
# check syntax # check syntax
rwx_log rwx_log
rwx_shellcheck "${rwx_main_root}" rwx_shellcheck "${RWX_ROOT_SYSTEM}"
} }
# fetch matching doc for given name # fetch matching doc for given name
@ -227,10 +228,10 @@ rwx_code_main() {
local modules_main="${1}" local modules_main="${1}"
local module modules_user local module modules_user
# find & source modules # find & source modules
modules_user="$(rwx_main_find "${rwx_code_root}")" modules_user="$(rwx_main_find "${RWX_SELF_USER}")"
while IFS= read -r module; do while IFS= read -r module; do
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "${rwx_code_root}/${module}.${RWX_MAIN_EXTENSION}" . "${RWX_SELF_USER}/${module}.${RWX_MAIN_EXTENSION}"
done <<EOF done <<EOF
${modules_user} ${modules_user}
EOF EOF
@ -238,7 +239,7 @@ EOF
while IFS= read -r module; do while IFS= read -r module; do
# cache main module # cache main module
_rwx_code="${_rwx_code}#. ${module} _rwx_code="${_rwx_code}#. ${module}
$(cat "${rwx_main_root}/${module}.${RWX_MAIN_EXTENSION}") $(cat "${RWX_ROOT_SYSTEM}/${module}.${RWX_MAIN_EXTENSION}")
" "
done <<EOF done <<EOF
${modules_main} ${modules_main}
@ -247,7 +248,7 @@ EOF
while IFS= read -r module; do while IFS= read -r module; do
# cache module # cache module
_rwx_code="${_rwx_code}#. ${module} _rwx_code="${_rwx_code}#. ${module}
$(cat "${rwx_code_root}/${module}.${RWX_MAIN_EXTENSION}") $(cat "${RWX_SELF_USER}/${module}.${RWX_MAIN_EXTENSION}")
" "
done <<EOF done <<EOF
${modules_user} ${modules_user}

View file

@ -8,21 +8,21 @@
# │ main │ constants │ # │ main │ constants │
# ╰──────┴───────────╯ # ╰──────┴───────────╯
# parent directory for the project
RWX_MAIN_PARENT="/usr/local/lib"
# name of the project itself
RWX_MAIN_NAME="rwx"
# name of the entrypoint module
RWX_MAIN_MODULE="main"
# extension of shell modules # extension of shell modules
RWX_MAIN_EXTENSION="sh" RWX_MAIN_EXTENSION="sh"
# name of the entrypoint module
RWX_MAIN_NAME="main"
# name of the project itself
RWX_SELF_NAME="rwx"
# ╭──────┬───────────╮ # ╭──────┬───────────╮
# │ main │ variables │ # │ main │ variables │
# ╰──────┴───────────╯ # ╰──────┴───────────╯
# TODO variablize
# system root directory of the project # system root directory of the project
rwx_main_root="${RWX_MAIN_PARENT}/${RWX_MAIN_NAME}" RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}"
# ╭──────┬──────╮ # ╭──────┬──────╮
# │ main │ find │ # │ main │ find │
@ -78,11 +78,11 @@ _rwx_main_log() {
rwx_main_main() { rwx_main_main() {
local module modules local module modules
# find & source modules # find & source modules
modules="$(rwx_main_find "${rwx_main_root}")" modules="$(rwx_main_find "${RWX_ROOT_SYSTEM}")"
while IFS= read -r module; do while IFS= read -r module; do
if [ "${module}" != "${RWX_MAIN_MODULE}" ]; then if [ "${module}" != "${RWX_MAIN_NAME}" ]; then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "${rwx_main_root}/${module}.${RWX_MAIN_EXTENSION}" . "${RWX_ROOT_SYSTEM}/${module}.${RWX_MAIN_EXTENSION}"
fi fi
done <<EOF done <<EOF
${modules} ${modules}

View file

@ -10,14 +10,14 @@
rwx_self_subset() { rwx_self_subset() {
local argument file root local argument file root
for argument in "${@}"; do for argument in "${@}"; do
root="${rwx_main_root}/${argument}" root="${RWX_ROOT_SYSTEM}/${argument}"
file="${argument}.${RWX_MAIN_EXTENSION}" file="${argument}.${RWX_MAIN_EXTENSION}"
if [ -d "${root}" ]; then if [ -d "${root}" ]; then
local file local file
for file in $(rwx_main_find "${root}"); do for file in $(rwx_main_find "${root}"); do
echo "${argument}/${file}.${RWX_MAIN_EXTENSION}" echo "${argument}/${file}.${RWX_MAIN_EXTENSION}"
done done
elif [ -f "${rwx_main_root}/${file}" ]; then elif [ -f "${RWX_ROOT_SYSTEM}/${file}" ]; then
echo "${file}" echo "${file}"
fi fi
done done
@ -38,7 +38,7 @@ rwx_self_write() {
files="$(rwx_self_subset "${@}")" files="$(rwx_self_subset "${@}")"
while IFS= read -r file; do while IFS= read -r file; do
text="${text} text="${text}
$(cat "${rwx_main_root}/${file}") $(cat "${RWX_ROOT_SYSTEM}/${file}")
" "
done <<EOF done <<EOF
${files} ${files}

View file

@ -43,7 +43,7 @@ RWX_COLOR_RED="$(_rwx_shell_color 32)"
# ╰───────┴───────────╯ # ╰───────┴───────────╯
rwx_shell_configure() { rwx_shell_configure() {
[ -n "${ENV}" ] || ENV="${rwx_code_main}" [ -n "${ENV}" ] || ENV="${RWX_MAIN_PATH}"
export ENV export ENV
# prompt # prompt
PS1="\$(rwx_shell_prompt \${?})" PS1="\$(rwx_shell_prompt \${?})"

View file

@ -41,7 +41,7 @@ rwx_test_doc() {
"main" \ "main" \
"alias/git" \ "alias/git" \
\ \
"RWX_MAIN_MODULE" \ "RWX_MAIN_NAME" \
\ \
"_rwx_code" \ "_rwx_code" \
\ \