At the end of a previous post about zsh key bindings, I was left with this syntax monstrosity:
alias binds='IFS=$'\''\n'\''
print -c -- $(bindkey | grep -v -e '\''\^\[\['\'' -e '\''\^\[O[A-H]"'\'' | sed -e '\''s/^"//g'\'' -e '\''s/" / /g'\'' -e '\''s/\^\[/⌥/g'\'')
unset IFS'
It hurts to look at, which inspired me to write a much longer function that accomplishes the same, plus some additional options.
bindlist v0.1
The help option explains what it does:
% bindlist -h
Usage:
bindlist list bindings
bindlist -h|--help print this message
Options:
-a --all include all bindings
-l --list single column output
-r --raw bindkey format
Called without options, the output looks like this:
There are probably better methods for everything this function does. I’m just amazed I got it to work at all. I learned a few things along the way.
I still haven’t figured how to enable the _gnu_generic
completions and suppress file completions. I figured out how to do one or the other, but not both, so settled on buildlist
being able to autocomplete its options. It also (harmlessly) lists completions for files, despite not excepting any arguments, which I hope to fix some day.
Update: bindlist v0.2
See: bindlist v0.2