Compare commits
No commits in common. "a3ea2e6ef06b088c6dc75d234de1eb55d9e12885" and "f9f93101ad7a5c4757f004716e5bc1b42103b04b" have entirely different histories.
a3ea2e6ef0
...
f9f93101ad
10 changed files with 94 additions and 127 deletions
16
readme.md
16
readme.md
|
@ -115,19 +115,7 @@ Two interpreted languages for flexibility.
|
||||||
* ffmpeg
|
* ffmpeg
|
||||||
* tmux
|
* tmux
|
||||||
* get unresolved path for new panes & windows
|
* get unresolved path for new panes & windows
|
||||||
* source code
|
* fully working doc function algorithm
|
||||||
* doc parsing algorithm
|
* self install aliases
|
||||||
* install commands
|
|
||||||
* remove existing before
|
|
||||||
* test required
|
|
||||||
* binaries
|
|
||||||
* modules
|
|
||||||
* handle dependencies
|
|
||||||
* binaries
|
|
||||||
* modules
|
|
||||||
* handle tasks
|
|
||||||
* readme.md / when
|
|
||||||
* FIXME
|
|
||||||
* TODO
|
|
||||||
|
|
||||||
### 6.2 [Further tasks](#when) {#when-further}
|
### 6.2 [Further tasks](#when) {#when-further}
|
||||||
|
|
55
sh/code.sh
55
sh/code.sh
|
@ -6,12 +6,6 @@
|
||||||
# │ code │ variables │
|
# │ code │ variables │
|
||||||
# ╰──────┴───────────╯
|
# ╰──────┴───────────╯
|
||||||
|
|
||||||
# TODO variablize
|
|
||||||
# path to the entrypoint main file of the project
|
|
||||||
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
|
||||||
# user root directory of the project
|
|
||||||
RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}"
|
|
||||||
|
|
||||||
# cache for the parsing awk script
|
# cache for the parsing awk script
|
||||||
_rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/code.awk")"
|
_rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/code.awk")"
|
||||||
# cache for code aliases
|
# cache for code aliases
|
||||||
|
@ -27,18 +21,6 @@ _rwx_code_functions=""
|
||||||
# cache for code variables
|
# cache for code variables
|
||||||
_rwx_code_variables=""
|
_rwx_code_variables=""
|
||||||
|
|
||||||
# ╭──────┬──────╮
|
|
||||||
# │ code │ help │
|
|
||||||
# ╰──────┴──────╯
|
|
||||||
|
|
||||||
# output help message
|
|
||||||
rwx_code_help() {
|
|
||||||
rwx_log \
|
|
||||||
"rwx_… = functions" \
|
|
||||||
" a__… = aliases" \
|
|
||||||
" u__… = user"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ╭──────┬─────────╮
|
# ╭──────┬─────────╮
|
||||||
# │ code │ install │
|
# │ code │ install │
|
||||||
# ╰──────┴─────────╯
|
# ╰──────┴─────────╯
|
||||||
|
@ -199,40 +181,3 @@ rwx_code_parse() {
|
||||||
--assign action="${action}" \
|
--assign action="${action}" \
|
||||||
"${_rwx_code_awk}"
|
"${_rwx_code_awk}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ╭──────┬──────╮
|
|
||||||
# │ code │ main │
|
|
||||||
# ╰──────┴──────╯
|
|
||||||
|
|
||||||
rwx_code_main() {
|
|
||||||
# source user root
|
|
||||||
rwx_main_source "${RWX_SELF_USER}"
|
|
||||||
# load code cache
|
|
||||||
rwx_code_load
|
|
||||||
# set 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
|
|
||||||
# context / command
|
|
||||||
if [ -n "${command}" ]; then
|
|
||||||
local function
|
|
||||||
# find the matching function
|
|
||||||
function="$(rwx_code_alias_function "${command}")"
|
|
||||||
if [ -n "${function}" ]; then
|
|
||||||
"${function}" "${@}"
|
|
||||||
fi
|
|
||||||
# context / shell
|
|
||||||
else
|
|
||||||
# run interactive extras
|
|
||||||
if rwx_shell_interactive; then
|
|
||||||
# help
|
|
||||||
rwx_log
|
|
||||||
rwx_code_help
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,20 +1,8 @@
|
||||||
# ╭───────╮
|
_rwx_cmd_cs() { rwx_crypt "${@}"; }
|
||||||
# │ crypt │
|
|
||||||
# ╰───────╯
|
|
||||||
|
|
||||||
# ╭───────┬───────────╮
|
|
||||||
# │ crypt │ constants │
|
|
||||||
# ╰───────┴───────────╯
|
|
||||||
|
|
||||||
# TODO variablize
|
|
||||||
RWX_CRYPT_ROOT="/data/home/user/crypt"
|
RWX_CRYPT_ROOT="/data/home/user/crypt"
|
||||||
RWX_CRYPT_VAR="/var/lib/crypt"
|
RWX_CRYPT_VAR="/var/lib/crypt"
|
||||||
|
|
||||||
# ╭───────┬───────────╮
|
|
||||||
# │ crypt │ functions │
|
|
||||||
# ╰───────┴───────────╯
|
|
||||||
|
|
||||||
#| cat
|
|
||||||
rwx_crypt_device() {
|
rwx_crypt_device() {
|
||||||
local device size
|
local device size
|
||||||
local index=0
|
local index=0
|
||||||
|
@ -37,17 +25,7 @@ rwx_crypt_device() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#| id
|
rwx_crypt() {
|
||||||
#| mkdir
|
|
||||||
#| qemu-nbd
|
|
||||||
#| cryptsetup
|
|
||||||
#| mount
|
|
||||||
#| umount
|
|
||||||
#| rmdir
|
|
||||||
#| cat
|
|
||||||
#| rm
|
|
||||||
#/ cs
|
|
||||||
rwx_crypt_setup() {
|
|
||||||
local action="${1}"
|
local action="${1}"
|
||||||
local action_close="close"
|
local action_close="close"
|
||||||
local action_open="open"
|
local action_open="open"
|
|
@ -1,12 +1,8 @@
|
||||||
# ╭────────╮
|
|
||||||
# │ ffmpeg │
|
|
||||||
# ╰────────╯
|
|
||||||
|
|
||||||
# ╭────────┬─────────┬───────╮
|
# ╭────────┬─────────┬───────╮
|
||||||
# │ ffmpeg │ devices │ reset │
|
# │ ffmpeg │ devices │ reset │
|
||||||
# ╰────────┴─────────┴───────╯
|
# ╰────────┴─────────┴───────╯
|
||||||
|
|
||||||
#/ rwx_ffmpeg_devices_reset
|
_rwx_cmd_rwx_ffmpeg_devices_reset() { rwx_ffmpeg_devices_reset "${@}"; }
|
||||||
rwx_ffmpeg_devices_reset() {
|
rwx_ffmpeg_devices_reset() {
|
||||||
local module="uvcvideo"
|
local module="uvcvideo"
|
||||||
modprobe --remove "${module}" &&
|
modprobe --remove "${module}" &&
|
||||||
|
|
|
@ -76,9 +76,9 @@ _rwx_log() {
|
||||||
local line
|
local line
|
||||||
for line in "${@}"; do
|
for line in "${@}"; do
|
||||||
if [ -n "${prefix}" ]; then
|
if [ -n "${prefix}" ]; then
|
||||||
_rwx_main_log "${prefix} ${line}"
|
__rwx_log "${prefix} ${line}"
|
||||||
else
|
else
|
||||||
_rwx_main_log "${line}"
|
__rwx_log "${line}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
76
sh/main.sh
76
sh/main.sh
|
@ -3,6 +3,15 @@
|
||||||
# │ main │
|
# │ main │
|
||||||
# ╰──────╯
|
# ╰──────╯
|
||||||
# main module
|
# main module
|
||||||
|
# * builtins
|
||||||
|
# * echo
|
||||||
|
# * printf
|
||||||
|
# * read
|
||||||
|
# * binaries
|
||||||
|
# * awk
|
||||||
|
# * cat
|
||||||
|
# * find
|
||||||
|
# * sed
|
||||||
|
|
||||||
# ╭──────┬───────────╮
|
# ╭──────┬───────────╮
|
||||||
# │ main │ constants │
|
# │ main │ constants │
|
||||||
|
@ -20,17 +29,21 @@ RWX_SELF_NAME="rwx"
|
||||||
# cache of all sourced code modules
|
# cache of all sourced code modules
|
||||||
_rwx_code=""
|
_rwx_code=""
|
||||||
|
|
||||||
# TODO variablize
|
|
||||||
# system root directory of the project
|
# system root directory of the project
|
||||||
RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}"
|
RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}"
|
||||||
|
# user root directory of the project
|
||||||
|
RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}"
|
||||||
|
|
||||||
|
# path to the entrypoint main file of the project
|
||||||
|
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
||||||
|
|
||||||
# ╭──────┬──────╮
|
# ╭──────┬──────╮
|
||||||
# │ main │ find │
|
# │ main │ find │
|
||||||
# ╰──────┴──────╯
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
# find directory’s files by extension
|
# find directory’s files by extension
|
||||||
#| find
|
#> find
|
||||||
#| sort
|
#> sort
|
||||||
rwx_find_extension() {
|
rwx_find_extension() {
|
||||||
local extension="${1}"
|
local extension="${1}"
|
||||||
local root="${2}"
|
local root="${2}"
|
||||||
|
@ -69,7 +82,7 @@ rwx_shell_interactive() {
|
||||||
# │ main │ log │
|
# │ main │ log │
|
||||||
# ╰──────┴─────╯
|
# ╰──────┴─────╯
|
||||||
|
|
||||||
_rwx_main_log() {
|
__rwx_log() {
|
||||||
if rwx_shell_interactive; then
|
if rwx_shell_interactive; then
|
||||||
[ ${#} -gt 0 ] || set -- ""
|
[ ${#} -gt 0 ] || set -- ""
|
||||||
local line
|
local line
|
||||||
|
@ -83,24 +96,24 @@ _rwx_main_log() {
|
||||||
# │ main │ source │
|
# │ main │ source │
|
||||||
# ╰──────┴────────╯
|
# ╰──────┴────────╯
|
||||||
|
|
||||||
# source code from root path but file
|
# source code from file path
|
||||||
rwx_main_source() {
|
rwx_source() {
|
||||||
local root="${1}"
|
local root="${1}"
|
||||||
[ -d "${root}" ] ||
|
[ -d "${root}" ] ||
|
||||||
return 1
|
return 1
|
||||||
local file="${2}"
|
local file="${2}"
|
||||||
local count module modules
|
local count module modules
|
||||||
count=0
|
count=0
|
||||||
_rwx_main_log "" \
|
__rwx_log "" \
|
||||||
". ${root}"
|
". ${root}"
|
||||||
modules="$(rwx_find_shell "${root}" "${file}")"
|
modules="$(rwx_find_shell "${root}" "${file}")"
|
||||||
while IFS= read -r module; do
|
while IFS= read -r module; do
|
||||||
count=$((count + 1))
|
count=$((count + 1))
|
||||||
_rwx_main_log "$(printf "%02d" "${count}") ${module%.sh}"
|
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
. "${root}/${module}"
|
. "${root}/${module}"
|
||||||
# cache code
|
# cache code
|
||||||
rwx_main_cache "${root}" "${module}"
|
rwx_cache "${root}" "${module}"
|
||||||
done <<EOF
|
done <<EOF
|
||||||
${modules}
|
${modules}
|
||||||
EOF
|
EOF
|
||||||
|
@ -112,8 +125,8 @@ EOF
|
||||||
|
|
||||||
# cache source code of a module
|
# cache source code of a module
|
||||||
# inside a global code variable
|
# inside a global code variable
|
||||||
#| cat
|
#> cat
|
||||||
rwx_main_cache() {
|
rwx_cache() {
|
||||||
local root="${1}"
|
local root="${1}"
|
||||||
local module="${2}"
|
local module="${2}"
|
||||||
local name="${module%.sh}"
|
local name="${module%.sh}"
|
||||||
|
@ -132,18 +145,43 @@ ${text}
|
||||||
# ╰──────┴──────╯
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
# run initial steps
|
# run initial steps
|
||||||
#< code
|
rwx_main() {
|
||||||
rwx_main_main() {
|
|
||||||
# cache main
|
# cache main
|
||||||
rwx_main_cache "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"
|
rwx_cache "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"
|
||||||
# source system root
|
# source system root
|
||||||
if ! rwx_main_source "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"; then
|
if ! rwx_source "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"; then
|
||||||
_rwx_main_log "Not a directory: ${RWX_ROOT_SYSTEM}"
|
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# run code main function
|
# source user root
|
||||||
rwx_code_main "${@}"
|
rwx_source "${RWX_SELF_USER}"
|
||||||
|
# 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
|
||||||
|
local function
|
||||||
|
# find the matching function
|
||||||
|
function="$(rwx_code_alias_function "${command}")"
|
||||||
|
if [ -n "${function}" ]; then
|
||||||
|
"${function}" "${@}"
|
||||||
|
fi
|
||||||
|
# context / shell
|
||||||
|
else
|
||||||
|
rwx_self_init
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ╭──────┬─────╮
|
||||||
|
# │ main │ run │
|
||||||
|
# ╰──────┴─────╯
|
||||||
|
|
||||||
# run main function
|
# run main function
|
||||||
rwx_main_main "${@}"
|
rwx_main "${@}"
|
||||||
|
|
27
sh/self.sh
27
sh/self.sh
|
@ -2,11 +2,35 @@
|
||||||
# │ self │
|
# │ self │
|
||||||
# ╰──────╯
|
# ╰──────╯
|
||||||
|
|
||||||
|
# ╭──────┬──────╮
|
||||||
|
# │ self │ help │
|
||||||
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
|
# output help message
|
||||||
|
rwx_self_help() {
|
||||||
|
rwx_log \
|
||||||
|
"rwx_… = functions" \
|
||||||
|
" a__… = aliases" \
|
||||||
|
" u__… = user"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬──────╮
|
||||||
|
# │ self │ init │
|
||||||
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
|
rwx_self_init() {
|
||||||
|
# run interactive extras
|
||||||
|
if rwx_shell_interactive; then
|
||||||
|
# help
|
||||||
|
rwx_log
|
||||||
|
rwx_self_help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# ╭──────┬────────╮
|
# ╭──────┬────────╮
|
||||||
# │ self │ subset │
|
# │ self │ subset │
|
||||||
# ╰──────┴────────╯
|
# ╰──────┴────────╯
|
||||||
|
|
||||||
# TODO move to code module
|
|
||||||
rwx_self_subset() {
|
rwx_self_subset() {
|
||||||
local argument file root
|
local argument file root
|
||||||
for argument in "${@}"; do
|
for argument in "${@}"; do
|
||||||
|
@ -27,7 +51,6 @@ rwx_self_subset() {
|
||||||
# │ self │ write │
|
# │ self │ write │
|
||||||
# ╰──────┴───────╯
|
# ╰──────┴───────╯
|
||||||
|
|
||||||
# TODO move to code module
|
|
||||||
rwx_self_write() {
|
rwx_self_write() {
|
||||||
local target="${1}"
|
local target="${1}"
|
||||||
if [ -n "${target}" ]; then
|
if [ -n "${target}" ]; then
|
||||||
|
|
|
@ -4,10 +4,9 @@
|
||||||
|
|
||||||
# based on currently running shell
|
# based on currently running shell
|
||||||
case "${RWX_SHELL}" in
|
case "${RWX_SHELL}" in
|
||||||
# continue if it can handle it
|
"bash") ;;
|
||||||
"bash") ;;
|
# skip illegal syntax to come
|
||||||
# otherwise skip incorrect names to come
|
*) return ;;
|
||||||
*) return ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# shellcheck disable=SC3033
|
# shellcheck disable=SC3033
|
||||||
|
|
|
@ -44,7 +44,7 @@ rwx_test_doc() {
|
||||||
\
|
\
|
||||||
"_rwx_code" \
|
"_rwx_code" \
|
||||||
\
|
\
|
||||||
"rwx_main_cache" \
|
"rwx_cache" \
|
||||||
\
|
\
|
||||||
"alias/batcat" \
|
"alias/batcat" \
|
||||||
"b" \
|
"b" \
|
||||||
|
|
|
@ -36,7 +36,7 @@ rwx_tmux_list() {
|
||||||
# │ tmux │ setup │
|
# │ tmux │ setup │
|
||||||
# ╰──────┴───────╯
|
# ╰──────┴───────╯
|
||||||
|
|
||||||
#/ rwx_tmux_setup
|
_rwx_cmd_rwx_tmux_setup() { rwx_tmux_setup "${@}"; }
|
||||||
rwx_tmux_setup() {
|
rwx_tmux_setup() {
|
||||||
local file script
|
local file script
|
||||||
if rwx_root; then
|
if rwx_root; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue