file
This commit is contained in:
parent
1cad82456e
commit
88f3ab499d
4 changed files with 39 additions and 24 deletions
26
sh/file.sh
Normal file
26
sh/file.sh
Normal 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
|
||||||
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
#! /usr/bin/env sh
|
#! /usr/bin/env sh
|
||||||
|
|
||||||
|
# ╭──────╮
|
||||||
|
# │ main │
|
||||||
|
# ╰──────╯
|
||||||
|
|
||||||
# ╭──────┬───────────╮
|
# ╭──────┬───────────╮
|
||||||
# │ main │ constants │
|
# │ main │ constants │
|
||||||
# ╰──────┴───────────╯
|
# ╰──────┴───────────╯
|
||||||
|
@ -127,12 +131,12 @@ rwx_source() {
|
||||||
|
|
||||||
# run initial steps
|
# run initial steps
|
||||||
rwx_main() {
|
rwx_main() {
|
||||||
# system root
|
# source system root
|
||||||
if ! rwx_source "${RWX_ROOT_SYSTEM}"; then
|
if ! rwx_source "${RWX_ROOT_SYSTEM}"; then
|
||||||
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
|
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# user root
|
# source user root
|
||||||
rwx_source "${RWX_SELF_USER}"
|
rwx_source "${RWX_SELF_USER}"
|
||||||
# context / command
|
# context / command
|
||||||
if [ -n "${RWX_COMMAND_NAME}" ]; then
|
if [ -n "${RWX_COMMAND_NAME}" ]; then
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# ╭──────╮
|
||||||
|
# │ tmux │
|
||||||
|
# ╰──────╯
|
||||||
|
|
||||||
# ╭──────┬───────╮
|
# ╭──────┬───────╮
|
||||||
# │ tmux │ setup │
|
# │ tmux │ setup │
|
||||||
# ╰──────┴───────╯
|
# ╰──────┴───────╯
|
||||||
|
|
25
sh/util.sh
25
sh/util.sh
|
@ -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}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue