After further study and experimentation, I’ve made some changes to the first version of my bindlist function.
bindlist
v0.3
Called without options, the output looks like this:
Change notes
v0.2
Refactored for my educational purposes. No changes to function behavior.
Patterns are now assembled in an array instead of a string:
patterns=(
"\^\[\[" # match "^[["
"\^\[O[A-H]" # match "^[OA"..."^[OH"
"^\"\\\M" # match "\M-^@"-"\M-^?"
"\"-\"~\"" # match " "-"~"
)
Previously, patterns were concatenated, in a function, like this:
for item in ${*}
do
_e_patterns=${_e_patterns}$(printf ' -e '\''%s'\' ${item})
done
Now patterns are concatenated like this, without calling a separate function:
for pat in $patterns
do
estring=$estring" -e '"$pat"'"
done
This method was used to execute a command with the concatenated patterns:
_cmd=$(printf 'grep -v%s\n' "${_e_patterns}")
_list=$(bindkey | eval "$(printf '%s' ${_cmd})")
Which has been simplified to this:
cmd="grep -v $estring"
_list=$(bindkey | eval $cmd)
v0.3
- remove unnecessary
cmd
variable use - edit usage typo