asterisk / editline / key bindings
Getting the Asterisk PBX CLI to work more like you’re used to from the (readline) bash shell can, be a time-saver.
For example, you may want reverse-i-search (^R
), backward word
deletion (^W
) and word skipping (^<arrow-left>
and
^<arrow-right>
).
It can be done, but you must configure the editline library in a
similar manner as you would configure .inputrc
.
Support for the .editrc
configuration file was added in May 2011 (git
commit
d508a921). The
commit message mentions it: you need to explicitly set the EDITRC
environment variable to the full path of your
editrc
file.
Thus, place the following in /etc/editrc
:
#REM:# Resist the urge to put blanks in this file!
#REM:# Double-quotes do matter for baskslash escapes.
#REM:#
#REM:# Backward-i-search: vi-search-prev behaves better than
#REM:# ed-search-prev-history and em-inc-search-prev. At least for
#REM:# someone who is used to the readline/bash ^R.
asterisk:bind "^R" vi-search-prev
#REM:#
#REM:# ^W, same as ALT-BS.
asterisk:bind "^W" ed-delete-prev-word
#REM:#
#REM:# ^left/^right to skip words.
asterisk:bind "\e[1;5D" vi-prev-word
asterisk:bind "\e[1;5C" vi-next-word
And add export EDITRC=/etc/editrc
to /etc/bash.bashrc
or to your
personal .bashrc
.
Update 2015-12-03
If you remove the asterisk:
prefixes from the above file, it works
perfectly for the standard MySQL client as well. That one doesn’t need
you to set the EDITRC
envvar, but reads ~/.editrc
by default.