asterisk / editline / key bindings

asterisk / editline / key bindings

  • Written by
    Walter Doekes
  • Published on

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.


Back to overview Newer post: Planned maintenance - router upgrade RUG RH POP (01:00-04:00 8 DEC 2015) Older post: Planned maintenance virtual servers TCN (01:00-06:00 27 NOV 2015)