diff --git a/sh/alias/git.sh b/sh/alias/git.sh index 35402d9..fe5380a 100644 --- a/sh/alias/git.sh +++ b/sh/alias/git.sh @@ -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 diff --git a/sh/file.sh b/sh/file.sh deleted file mode 100644 index becca76..0000000 --- a/sh/file.sh +++ /dev/null @@ -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 -} diff --git a/sh/log/log.sh b/sh/log/log.sh index a3013e8..b921d45 100644 --- a/sh/log/log.sh +++ b/sh/log/log.sh @@ -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() { diff --git a/sh/main.sh b/sh/main.sh index 63ca6bf..40fbf17 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -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 "${@}" diff --git a/sh/tmux.sh b/sh/tmux.sh index a29ec26..0294e7f 100644 --- a/sh/tmux.sh +++ b/sh/tmux.sh @@ -1,7 +1,3 @@ -# ╭──────╮ -# │ tmux │ -# ╰──────╯ - # ╭──────┬───────╮ # │ tmux │ setup │ # ╰──────┴───────╯ diff --git a/sh/util.sh b/sh/util.sh index a3c53bf..cbcd67a 100644 --- a/sh/util.sh +++ b/sh/util.sh @@ -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}"