Compare commits
No commits in common. "747d0694493432246ddcef95c3c86faa8ba048ae" and "aeff5a62f2fa70d939530e6bf44b9b9ace344287" have entirely different histories.
747d069449
...
aeff5a62f2
7 changed files with 54 additions and 108 deletions
|
@ -1,4 +1,4 @@
|
|||
#= b
|
||||
b() { a__bat "${@}"; }
|
||||
a__bat() {
|
||||
batcat \
|
||||
"${@}"
|
||||
|
|
12
sh/alias/gpg.sh
Normal file
12
sh/alias/gpg.sh
Normal file
|
@ -0,0 +1,12 @@
|
|||
# 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,14 +1,4 @@
|
|||
# functions to handle gpg
|
||||
|
||||
# turn gpg agent off
|
||||
#= gak
|
||||
rwx_gpg_agent_kill() {
|
||||
gpgconf \
|
||||
--kill "gpg-agent"
|
||||
}
|
||||
|
||||
# bind gpg agent to current tty
|
||||
#= gau
|
||||
rwx_gpg_agent_update() {
|
||||
gpg-connect-agent \
|
||||
updatestartuptty \
|
||||
|
|
23
sh/main.awk
23
sh/main.awk
|
@ -6,16 +6,13 @@ function append(line) {
|
|||
}
|
||||
|
||||
function output(name, type) {
|
||||
print "↙ " type
|
||||
print name
|
||||
print name " ← " type
|
||||
print doc
|
||||
exit
|
||||
}
|
||||
|
||||
function reset() {
|
||||
if (f == "") {
|
||||
doc = ""
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
|
@ -33,14 +30,13 @@ BEGIN {
|
|||
RE_ALIAS = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END
|
||||
RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END
|
||||
RE_CONSTANT = RE_BEGIN RE_CONST RE_SET RE_END
|
||||
RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END
|
||||
RE_DOC = RE_BEGIN "#" RE_SPACE RE_ANY RE_END
|
||||
RE_FUNCTION = RE_BEGIN RE_VAR RE_FUNC RE_END
|
||||
RE_MODULE = 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
|
||||
|
||||
alias = 0
|
||||
f = ""
|
||||
reset()
|
||||
module = 0
|
||||
}
|
||||
|
@ -52,7 +48,7 @@ BEGIN {
|
|||
} else if (match($0, RE_FUNCTION, m)) {
|
||||
n = split(doc, array, "\n")
|
||||
for (i = 1; i<= n; i++) {
|
||||
print array[i] " " m[1]
|
||||
print array[i] " = " m[1]
|
||||
}
|
||||
reset()
|
||||
} else {
|
||||
|
@ -63,11 +59,7 @@ BEGIN {
|
|||
if (match($0, RE_SHEBANG, m)) {
|
||||
append("! " m[1])
|
||||
} else if (match($0, RE_DOC, m)) {
|
||||
if (f) {
|
||||
append($0)
|
||||
} else {
|
||||
append(m[1])
|
||||
}
|
||||
} else if (match($0, RE_ALIAS, m)) {
|
||||
append("= " m[1])
|
||||
if (m[1] == target) {
|
||||
|
@ -93,15 +85,12 @@ BEGIN {
|
|||
module = 1
|
||||
}
|
||||
} else if (match($0, RE_FUNCTION, m)) {
|
||||
f = m[1]
|
||||
} else if (match($0, RE_CLOSE, m)) {
|
||||
if (alias) {
|
||||
print "= " target
|
||||
output(f, "function")
|
||||
} else if (f == target) {
|
||||
output(f, "function")
|
||||
output(m[1], "function")
|
||||
} else if (m[1] == target) {
|
||||
output(target, "function")
|
||||
} else {
|
||||
f = ""
|
||||
reset()
|
||||
}
|
||||
} else {
|
||||
|
|
38
sh/main.sh
38
sh/main.sh
|
@ -94,11 +94,11 @@ rwx_source() {
|
|||
[ -d "${root}" ] ||
|
||||
return 1
|
||||
local file="${2}"
|
||||
local count module modules
|
||||
local count module
|
||||
count=0
|
||||
__rwx_log "" \
|
||||
". ${root}"
|
||||
modules="$(rwx_find_shell "${root}" "${file}")"
|
||||
local modules="$(rwx_find_shell "${root}" "${file}")"
|
||||
while IFS= read -r module; do
|
||||
count=$((count + 1))
|
||||
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
|
||||
|
@ -172,32 +172,24 @@ RWX_REGEX_CONSTANT="[_A-Z][_0-9A-Z]*"
|
|||
RWX_REGEX_FUNCTION="[_A-Za-z][_0-9A-Za-z]*"
|
||||
RWX_REGEX_SET="=.*"
|
||||
RWX_REGEX_SPACES="[[:space:]]*"
|
||||
RWX_REGEX_VARIABLE="[_a-z][_0-9a-z]*"
|
||||
|
||||
RWX_REGEX_BEGIN="^"
|
||||
RWX_REGEX_BEGIN="^${RWX_REGEX_SPACES}"
|
||||
RWX_REGEX_OPEN="\
|
||||
${RWX_REGEX_SPACES}(${RWX_REGEX_SPACES})${RWX_REGEX_SPACES}{.*"
|
||||
|
||||
RWX_REGEX_TARGET_CONSTANT="\
|
||||
${RWX_REGEX_BEGIN}\\(${RWX_REGEX_CONSTANT}\\)${RWX_REGEX_SET}"
|
||||
RWX_REGEX_TARGET_DOC="\
|
||||
${RWX_REGEX_BEGIN}${RWX_REGEX_SPACES}# \\(.*\\)${RWX_REGEX_SPACES}\$"
|
||||
${RWX_REGEX_BEGIN}# \\(.*\\)${RWX_REGEX_SPACES}\$"
|
||||
RWX_REGEX_TARGET_FUNCTION="\
|
||||
${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() {
|
||||
# parse aliases
|
||||
local line text
|
||||
local line
|
||||
RWX_ALIASES="$(rwx_parse_aliases)"
|
||||
while IFS= read -r line; do
|
||||
text="$(echo "${line}" | sed "s| |() { |")"
|
||||
text="${text} \"\${@}\"; }"
|
||||
eval "${text}"
|
||||
eval "${line/ = /() { } \"\${@}\"; }"
|
||||
done <<EOF
|
||||
${RWX_ALIASES}
|
||||
EOF
|
||||
|
@ -205,8 +197,6 @@ EOF
|
|||
RWX_CONSTANTS="$(rwx_parse_constants)"
|
||||
# parse functions
|
||||
RWX_FUNCTIONS="$(rwx_parse_functions)"
|
||||
# parse variables
|
||||
_rwx_code_variables="$(rwx_parse_variables)"
|
||||
}
|
||||
rwx_parse_aliases() {
|
||||
printf "%s" "${_rwx_code}" |
|
||||
|
@ -215,25 +205,24 @@ rwx_parse_aliases() {
|
|||
--file "${RWX_AWK}"
|
||||
}
|
||||
rwx_parse_constants() {
|
||||
printf "%s" "${_rwx_code}" |
|
||||
printf "%s\n" "${_rwx_code}" |
|
||||
sed --silent "s|${RWX_REGEX_TARGET_CONSTANT}|\\1|p"
|
||||
}
|
||||
rwx_parse_functions() {
|
||||
printf "%s" "${_rwx_code}" |
|
||||
printf "%s\n" "${_rwx_code}" |
|
||||
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 │
|
||||
# ╰──────┴──────╯
|
||||
|
||||
#= rt
|
||||
rwx_test() {
|
||||
local item
|
||||
# TODO CODE
|
||||
# TODO CONSTANTS
|
||||
# TODO functions
|
||||
# TODO variables
|
||||
set \
|
||||
"main" \
|
||||
"alias/git" \
|
||||
|
@ -244,8 +233,7 @@ rwx_test() {
|
|||
\
|
||||
"rwx_cache" \
|
||||
\
|
||||
"alias/batcat" \
|
||||
"b"
|
||||
"gsc"
|
||||
for item in "${@}"; do
|
||||
echo
|
||||
rwx_doc "${item}"
|
||||
|
|
35
sh/self.sh
35
sh/self.sh
|
@ -1,38 +1,7 @@
|
|||
# self
|
||||
# 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
|
||||
#= rd
|
||||
rwx_doc() {
|
||||
local name="${1}"
|
||||
[ -n "${name}" ] || return
|
||||
|
@ -222,10 +191,10 @@ rwx_self_write() {
|
|||
local target="${1}"
|
||||
if [ -n "${target}" ]; then
|
||||
shift
|
||||
local file files text
|
||||
local file text
|
||||
text="#! /usr/bin/env sh
|
||||
"
|
||||
files="$(rwx_self_subset "${@}")"
|
||||
local files="$(rwx_self_subset "${@}")"
|
||||
while IFS= read -r file; do
|
||||
text="${text}
|
||||
$(cat "${RWX_ROOT_SYSTEM}/${file}")
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#= tma
|
||||
rwx_tmux_attach() {
|
||||
local server="${1}"
|
||||
if [ -n "${server}" ]; then
|
||||
if [ "${server}" ]; then
|
||||
tmux -L "${server}" attach-session
|
||||
else
|
||||
rwx_tmux_list
|
||||
|
@ -17,7 +17,7 @@ rwx_tmux_attach() {
|
|||
#= tmk
|
||||
rwx_tmux_kill() {
|
||||
local server="${1}"
|
||||
if [ -n "${server}" ]; then
|
||||
if [ "${server}" ]; then
|
||||
tmux -L "${server}" kill-server 2>"/dev/null"
|
||||
else
|
||||
rwx_tmux_list
|
||||
|
@ -27,9 +27,7 @@ rwx_tmux_kill() {
|
|||
# list
|
||||
#= tml
|
||||
rwx_tmux_list() {
|
||||
local user_id
|
||||
user_id="$(id --user)"
|
||||
ls "/tmp/tmux-${user_id}"
|
||||
ls "/tmp/tmux-$(id --user)"
|
||||
}
|
||||
|
||||
# ╭──────┬───────╮
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue