Compare commits
22 commits
aeff5a62f2
...
747d069449
Author | SHA1 | Date | |
---|---|---|---|
747d069449 | |||
44f415a8e8 | |||
9327161e72 | |||
75487be90a | |||
c4b63c5de6 | |||
5c5464d4ae | |||
249aa0b19c | |||
de0dd93a71 | |||
4b55ac1155 | |||
69e71ee1a3 | |||
c21cbb1e98 | |||
715a13e871 | |||
20bc9fc4fb | |||
9910ad3942 | |||
513d09f797 | |||
1d6a7bab9b | |||
7c65fb2e25 | |||
58a0ca7c16 | |||
030beb5ebe | |||
d0596131ca | |||
b6c962abde | |||
2b5fe88eee |
7 changed files with 108 additions and 54 deletions
|
@ -1,4 +1,4 @@
|
||||||
b() { a__bat "${@}"; }
|
#= b
|
||||||
a__bat() {
|
a__bat() {
|
||||||
batcat \
|
batcat \
|
||||||
"${@}"
|
"${@}"
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
# turn gpg agent off
|
|
||||||
gak() { a__gpg_agent_kill "${@}"; }
|
|
||||||
a__gpg_agent_kill() {
|
|
||||||
gpgconf \
|
|
||||||
--kill "gpg-agent"
|
|
||||||
}
|
|
||||||
|
|
||||||
# bind gpg agent to current tty
|
|
||||||
gau() { a__gpg_agent_update "${@}"; }
|
|
||||||
a__gpg_agent_update() {
|
|
||||||
rwx_gpg_agent_update
|
|
||||||
}
|
|
10
sh/gpg.sh
10
sh/gpg.sh
|
@ -1,4 +1,14 @@
|
||||||
|
# functions to handle gpg
|
||||||
|
|
||||||
|
# turn gpg agent off
|
||||||
|
#= gak
|
||||||
|
rwx_gpg_agent_kill() {
|
||||||
|
gpgconf \
|
||||||
|
--kill "gpg-agent"
|
||||||
|
}
|
||||||
|
|
||||||
# bind gpg agent to current tty
|
# bind gpg agent to current tty
|
||||||
|
#= gau
|
||||||
rwx_gpg_agent_update() {
|
rwx_gpg_agent_update() {
|
||||||
gpg-connect-agent \
|
gpg-connect-agent \
|
||||||
updatestartuptty \
|
updatestartuptty \
|
||||||
|
|
23
sh/main.awk
23
sh/main.awk
|
@ -6,14 +6,17 @@ function append(line) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function output(name, type) {
|
function output(name, type) {
|
||||||
print name " ← " type
|
print "↙ " type
|
||||||
|
print name
|
||||||
print doc
|
print doc
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
|
if (f == "") {
|
||||||
doc = ""
|
doc = ""
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
RE_ANY = "(.*)"
|
RE_ANY = "(.*)"
|
||||||
|
@ -30,13 +33,14 @@ BEGIN {
|
||||||
RE_ALIAS = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END
|
RE_ALIAS = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END
|
||||||
RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END
|
RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END
|
||||||
RE_CONSTANT = RE_BEGIN RE_CONST RE_SET RE_END
|
RE_CONSTANT = RE_BEGIN RE_CONST RE_SET RE_END
|
||||||
RE_DOC = RE_BEGIN "#" RE_SPACE RE_ANY RE_END
|
RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END
|
||||||
RE_FUNCTION = RE_BEGIN RE_VAR RE_FUNC RE_END
|
RE_FUNCTION = RE_BEGIN RE_VAR RE_FUNC RE_END
|
||||||
RE_MODULE = RE_BEGIN "#." RE_SPACES RE_ANY RE_END
|
RE_MODULE = RE_BEGIN "#." RE_SPACES RE_ANY RE_END
|
||||||
RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END
|
RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END
|
||||||
RE_VARIABLE = RE_BEGIN RE_VAR RE_SET RE_END
|
RE_VARIABLE = RE_BEGIN RE_VAR RE_SET RE_END
|
||||||
|
|
||||||
alias = 0
|
alias = 0
|
||||||
|
f = ""
|
||||||
reset()
|
reset()
|
||||||
module = 0
|
module = 0
|
||||||
}
|
}
|
||||||
|
@ -48,7 +52,7 @@ BEGIN {
|
||||||
} else if (match($0, RE_FUNCTION, m)) {
|
} else if (match($0, RE_FUNCTION, m)) {
|
||||||
n = split(doc, array, "\n")
|
n = split(doc, array, "\n")
|
||||||
for (i = 1; i<= n; i++) {
|
for (i = 1; i<= n; i++) {
|
||||||
print array[i] " = " m[1]
|
print array[i] " " m[1]
|
||||||
}
|
}
|
||||||
reset()
|
reset()
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,7 +63,11 @@ BEGIN {
|
||||||
if (match($0, RE_SHEBANG, m)) {
|
if (match($0, RE_SHEBANG, m)) {
|
||||||
append("! " m[1])
|
append("! " m[1])
|
||||||
} else if (match($0, RE_DOC, m)) {
|
} else if (match($0, RE_DOC, m)) {
|
||||||
|
if (f) {
|
||||||
|
append($0)
|
||||||
|
} else {
|
||||||
append(m[1])
|
append(m[1])
|
||||||
|
}
|
||||||
} else if (match($0, RE_ALIAS, m)) {
|
} else if (match($0, RE_ALIAS, m)) {
|
||||||
append("= " m[1])
|
append("= " m[1])
|
||||||
if (m[1] == target) {
|
if (m[1] == target) {
|
||||||
|
@ -85,12 +93,15 @@ BEGIN {
|
||||||
module = 1
|
module = 1
|
||||||
}
|
}
|
||||||
} else if (match($0, RE_FUNCTION, m)) {
|
} else if (match($0, RE_FUNCTION, m)) {
|
||||||
|
f = m[1]
|
||||||
|
} else if (match($0, RE_CLOSE, m)) {
|
||||||
if (alias) {
|
if (alias) {
|
||||||
print "= " target
|
print "= " target
|
||||||
output(m[1], "function")
|
output(f, "function")
|
||||||
} else if (m[1] == target) {
|
} else if (f == target) {
|
||||||
output(target, "function")
|
output(f, "function")
|
||||||
} else {
|
} else {
|
||||||
|
f = ""
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
38
sh/main.sh
38
sh/main.sh
|
@ -94,11 +94,11 @@ rwx_source() {
|
||||||
[ -d "${root}" ] ||
|
[ -d "${root}" ] ||
|
||||||
return 1
|
return 1
|
||||||
local file="${2}"
|
local file="${2}"
|
||||||
local count module
|
local count module modules
|
||||||
count=0
|
count=0
|
||||||
__rwx_log "" \
|
__rwx_log "" \
|
||||||
". ${root}"
|
". ${root}"
|
||||||
local 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_log "$(printf "%02d" "${count}") ${module%.sh}"
|
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
|
||||||
|
@ -172,24 +172,32 @@ RWX_REGEX_CONSTANT="[_A-Z][_0-9A-Z]*"
|
||||||
RWX_REGEX_FUNCTION="[_A-Za-z][_0-9A-Za-z]*"
|
RWX_REGEX_FUNCTION="[_A-Za-z][_0-9A-Za-z]*"
|
||||||
RWX_REGEX_SET="=.*"
|
RWX_REGEX_SET="=.*"
|
||||||
RWX_REGEX_SPACES="[[:space:]]*"
|
RWX_REGEX_SPACES="[[:space:]]*"
|
||||||
|
RWX_REGEX_VARIABLE="[_a-z][_0-9a-z]*"
|
||||||
|
|
||||||
RWX_REGEX_BEGIN="^${RWX_REGEX_SPACES}"
|
RWX_REGEX_BEGIN="^"
|
||||||
RWX_REGEX_OPEN="\
|
RWX_REGEX_OPEN="\
|
||||||
${RWX_REGEX_SPACES}(${RWX_REGEX_SPACES})${RWX_REGEX_SPACES}{.*"
|
${RWX_REGEX_SPACES}(${RWX_REGEX_SPACES})${RWX_REGEX_SPACES}{.*"
|
||||||
|
|
||||||
RWX_REGEX_TARGET_CONSTANT="\
|
RWX_REGEX_TARGET_CONSTANT="\
|
||||||
${RWX_REGEX_BEGIN}\\(${RWX_REGEX_CONSTANT}\\)${RWX_REGEX_SET}"
|
${RWX_REGEX_BEGIN}\\(${RWX_REGEX_CONSTANT}\\)${RWX_REGEX_SET}"
|
||||||
RWX_REGEX_TARGET_DOC="\
|
RWX_REGEX_TARGET_DOC="\
|
||||||
${RWX_REGEX_BEGIN}# \\(.*\\)${RWX_REGEX_SPACES}\$"
|
${RWX_REGEX_BEGIN}${RWX_REGEX_SPACES}# \\(.*\\)${RWX_REGEX_SPACES}\$"
|
||||||
RWX_REGEX_TARGET_FUNCTION="\
|
RWX_REGEX_TARGET_FUNCTION="\
|
||||||
${RWX_REGEX_BEGIN}\\(${RWX_REGEX_FUNCTION}\\)${RWX_REGEX_OPEN}"
|
${RWX_REGEX_BEGIN}\\(${RWX_REGEX_FUNCTION}\\)${RWX_REGEX_OPEN}"
|
||||||
|
RWX_REGEX_TARGET_VARIABLE="\
|
||||||
|
${RWX_REGEX_BEGIN}\\(${RWX_REGEX_VARIABLE}\\)${RWX_REGEX_SET}"
|
||||||
|
|
||||||
|
# cache for code variables
|
||||||
|
_rwx_code_variables=""
|
||||||
|
|
||||||
rwx_parse_code() {
|
rwx_parse_code() {
|
||||||
# parse aliases
|
# parse aliases
|
||||||
local line
|
local line text
|
||||||
RWX_ALIASES="$(rwx_parse_aliases)"
|
RWX_ALIASES="$(rwx_parse_aliases)"
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
eval "${line/ = /() { } \"\${@}\"; }"
|
text="$(echo "${line}" | sed "s| |() { |")"
|
||||||
|
text="${text} \"\${@}\"; }"
|
||||||
|
eval "${text}"
|
||||||
done <<EOF
|
done <<EOF
|
||||||
${RWX_ALIASES}
|
${RWX_ALIASES}
|
||||||
EOF
|
EOF
|
||||||
|
@ -197,6 +205,8 @@ EOF
|
||||||
RWX_CONSTANTS="$(rwx_parse_constants)"
|
RWX_CONSTANTS="$(rwx_parse_constants)"
|
||||||
# parse functions
|
# parse functions
|
||||||
RWX_FUNCTIONS="$(rwx_parse_functions)"
|
RWX_FUNCTIONS="$(rwx_parse_functions)"
|
||||||
|
# parse variables
|
||||||
|
_rwx_code_variables="$(rwx_parse_variables)"
|
||||||
}
|
}
|
||||||
rwx_parse_aliases() {
|
rwx_parse_aliases() {
|
||||||
printf "%s" "${_rwx_code}" |
|
printf "%s" "${_rwx_code}" |
|
||||||
|
@ -205,24 +215,25 @@ rwx_parse_aliases() {
|
||||||
--file "${RWX_AWK}"
|
--file "${RWX_AWK}"
|
||||||
}
|
}
|
||||||
rwx_parse_constants() {
|
rwx_parse_constants() {
|
||||||
printf "%s\n" "${_rwx_code}" |
|
printf "%s" "${_rwx_code}" |
|
||||||
sed --silent "s|${RWX_REGEX_TARGET_CONSTANT}|\\1|p"
|
sed --silent "s|${RWX_REGEX_TARGET_CONSTANT}|\\1|p"
|
||||||
}
|
}
|
||||||
rwx_parse_functions() {
|
rwx_parse_functions() {
|
||||||
printf "%s\n" "${_rwx_code}" |
|
printf "%s" "${_rwx_code}" |
|
||||||
sed --silent "s|${RWX_REGEX_TARGET_FUNCTION}|\\1|p"
|
sed --silent "s|${RWX_REGEX_TARGET_FUNCTION}|\\1|p"
|
||||||
}
|
}
|
||||||
|
rwx_parse_variables() {
|
||||||
|
printf "%s" "${_rwx_code}" |
|
||||||
|
sed --silent "s|${RWX_REGEX_TARGET_VARIABLE}|\\1|p"
|
||||||
|
}
|
||||||
|
|
||||||
# ╭──────┬──────╮
|
# ╭──────┬──────╮
|
||||||
# │ main │ test │
|
# │ main │ test │
|
||||||
# ╰──────┴──────╯
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
|
#= rt
|
||||||
rwx_test() {
|
rwx_test() {
|
||||||
local item
|
local item
|
||||||
# TODO CODE
|
|
||||||
# TODO CONSTANTS
|
|
||||||
# TODO functions
|
|
||||||
# TODO variables
|
|
||||||
set \
|
set \
|
||||||
"main" \
|
"main" \
|
||||||
"alias/git" \
|
"alias/git" \
|
||||||
|
@ -233,7 +244,8 @@ rwx_test() {
|
||||||
\
|
\
|
||||||
"rwx_cache" \
|
"rwx_cache" \
|
||||||
\
|
\
|
||||||
"gsc"
|
"alias/batcat" \
|
||||||
|
"b"
|
||||||
for item in "${@}"; do
|
for item in "${@}"; do
|
||||||
echo
|
echo
|
||||||
rwx_doc "${item}"
|
rwx_doc "${item}"
|
||||||
|
|
35
sh/self.sh
35
sh/self.sh
|
@ -1,7 +1,38 @@
|
||||||
# self
|
# self
|
||||||
# module
|
# module
|
||||||
|
|
||||||
|
# show the cached code
|
||||||
|
#= rc
|
||||||
|
rwx_code() {
|
||||||
|
echo "${_rwx_code}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# show the cached aliases
|
||||||
|
#= rca
|
||||||
|
rwx_code_aliases() {
|
||||||
|
echo "${RWX_ALIASES}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# show the cached constants
|
||||||
|
#= rcc
|
||||||
|
rwx_code_constants() {
|
||||||
|
echo "${RWX_CONSTANTS}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# show the cached functions
|
||||||
|
#= rcf
|
||||||
|
rwx_code_functions() {
|
||||||
|
echo "${RWX_FUNCTIONS}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# show the cached variables
|
||||||
|
#= rcv
|
||||||
|
rwx_code_variables() {
|
||||||
|
echo "${_rwx_code_variables}"
|
||||||
|
}
|
||||||
|
|
||||||
# meta doc
|
# meta doc
|
||||||
|
#= rd
|
||||||
rwx_doc() {
|
rwx_doc() {
|
||||||
local name="${1}"
|
local name="${1}"
|
||||||
[ -n "${name}" ] || return
|
[ -n "${name}" ] || return
|
||||||
|
@ -191,10 +222,10 @@ rwx_self_write() {
|
||||||
local target="${1}"
|
local target="${1}"
|
||||||
if [ -n "${target}" ]; then
|
if [ -n "${target}" ]; then
|
||||||
shift
|
shift
|
||||||
local file text
|
local file files text
|
||||||
text="#! /usr/bin/env sh
|
text="#! /usr/bin/env sh
|
||||||
"
|
"
|
||||||
local 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_ROOT_SYSTEM}/${file}")
|
$(cat "${RWX_ROOT_SYSTEM}/${file}")
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#= tma
|
#= tma
|
||||||
rwx_tmux_attach() {
|
rwx_tmux_attach() {
|
||||||
local server="${1}"
|
local server="${1}"
|
||||||
if [ "${server}" ]; then
|
if [ -n "${server}" ]; then
|
||||||
tmux -L "${server}" attach-session
|
tmux -L "${server}" attach-session
|
||||||
else
|
else
|
||||||
rwx_tmux_list
|
rwx_tmux_list
|
||||||
|
@ -17,7 +17,7 @@ rwx_tmux_attach() {
|
||||||
#= tmk
|
#= tmk
|
||||||
rwx_tmux_kill() {
|
rwx_tmux_kill() {
|
||||||
local server="${1}"
|
local server="${1}"
|
||||||
if [ "${server}" ]; then
|
if [ -n "${server}" ]; then
|
||||||
tmux -L "${server}" kill-server 2>"/dev/null"
|
tmux -L "${server}" kill-server 2>"/dev/null"
|
||||||
else
|
else
|
||||||
rwx_tmux_list
|
rwx_tmux_list
|
||||||
|
@ -27,7 +27,9 @@ rwx_tmux_kill() {
|
||||||
# list
|
# list
|
||||||
#= tml
|
#= tml
|
||||||
rwx_tmux_list() {
|
rwx_tmux_list() {
|
||||||
ls "/tmp/tmux-$(id --user)"
|
local user_id
|
||||||
|
user_id="$(id --user)"
|
||||||
|
ls "/tmp/tmux-${user_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ╭──────┬───────╮
|
# ╭──────┬───────╮
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue