filter/aliases
This commit is contained in:
parent
fa9a2435a4
commit
030be80a01
2 changed files with 16 additions and 4 deletions
|
@ -36,7 +36,7 @@ BEGIN {
|
||||||
RE_END = RE_SPACES "$"
|
RE_END = RE_SPACES "$"
|
||||||
RE_FUNC = RE_SPACES "\\(" RE_SPACES "\\)" RE_SPACES "{"
|
RE_FUNC = RE_SPACES "\\(" RE_SPACES "\\)" RE_SPACES "{"
|
||||||
|
|
||||||
RE_ALIAS = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END
|
re["alias"] = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END
|
||||||
RE_BINARY = RE_BEGIN "#\\|" RE_SPACES RE_VAR RE_END
|
RE_BINARY = 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_COMMAND = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END
|
RE_COMMAND = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END
|
||||||
|
@ -58,8 +58,8 @@ BEGIN {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
if (action == "aliases") {
|
if (action == "filter") {
|
||||||
if (match($0, RE_ALIAS, m)) {
|
if (match($0, re[target], m)) {
|
||||||
print m[1]
|
print m[1]
|
||||||
}
|
}
|
||||||
} else if (action == "binaries") {
|
} else if (action == "binaries") {
|
||||||
|
|
|
@ -107,6 +107,18 @@ rwx_code_awk() {
|
||||||
echo "${_rwx_code_awk}"
|
echo "${_rwx_code_awk}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# call awk for action with target
|
||||||
|
rwx_code_action_target() {
|
||||||
|
local action="${1}"
|
||||||
|
local target="${2}"
|
||||||
|
[ -n "${action}" ] || return
|
||||||
|
rwx_code_cache |
|
||||||
|
awk \
|
||||||
|
-v action="${action}" \
|
||||||
|
-v target="${target}" \
|
||||||
|
"${_rwx_code_awk}"
|
||||||
|
}
|
||||||
|
|
||||||
# show the cached aliases
|
# show the cached aliases
|
||||||
#= rca
|
#= rca
|
||||||
rwx_code_aliases() {
|
rwx_code_aliases() {
|
||||||
|
@ -232,7 +244,7 @@ EOF
|
||||||
${_rwx_code_commands_functions}
|
${_rwx_code_commands_functions}
|
||||||
EOF
|
EOF
|
||||||
# parse aliases
|
# parse aliases
|
||||||
_rwx_code_aliases="$(rwx_code_parse "aliases")"
|
_rwx_code_aliases="$(rwx_code_action_target "filter" "alias")"
|
||||||
# parse binaries
|
# parse binaries
|
||||||
_rwx_code_binaries="$(rwx_code_parse "binaries")"
|
_rwx_code_binaries="$(rwx_code_parse "binaries")"
|
||||||
# parse commands
|
# parse commands
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue