Issues With Asterisk CLI
Hello,
I have Asterisk 16.2 on Debian.
In the Asterisk CLI, I would like to change 2 things:
1) change the keybindings for commandline editing
(what in bash is called “readline” editing of the command line)
The CLI is missing some very useful keybindings, and even worse, has misconfigured others, For instance, “ctrl”+”w” should delete the last word backward. But the CLI deletes whole line (same as “ctrl” + “u”).
Also, I would like to be able to use the “PageUp” and “PageDown” for history-search-forward/backward, as I can use in Bash (defined in my
/etc/inputrc). In short, I would like to be able to modify the asterisk CLI line editing capabilities
Does Asterisk use the readline library? Does it use /etc/inputrc ?
Can the behavior described above be configured ?
2) I would like to be able to change the color of the asterisk prompt as described here: https://www.voip-info.org/asterisk-cli-prompt/
I tried all possible permutations, but none work:
ASTERISK_PROMPT=”%Cn[COLOR_BLUE] %H: ” asterisk -vvvvvvr ASTERISK_PROMPT=”%Cn[32;128] %H: ” asterisk -vvvvvvr ASTERISK_PROMPT=”%Cn[32;] %H: ” asterisk -vvvvvvr ASTERISK_PROMPT=”%Cn[;32] %H: ” asterisk -vvvvvvr ASTERISK_PROMPT=”%Cn[;COLOR_CYAN] %H: ” asterisk -vvvvvvr ASTERISK_PROMPT=”%Cn[32|128] %H: ” asterisk -vvvvvvr
Item 2) is just a cosmetic thing. but item 1) is very important for me. Commandline shortcuts are great productivity tool. I can’t understand that this is not bothering other people. Also, if somebody thought commandline editing in Asterisk CLI was a good idea, why did they not adhere to the standard behaviour (ie, ctrl+w) ?
Also, when exiting the CLI, instead of having to type “exit” or “quit”, would it be possible to use “ctrl”+”d” like any other CLI ?
thanks,
—
2 thoughts on - Issues With Asterisk CLI
It uses the editline library and all usage of it is within asterisk.c[1]. There is no configuration ability as far as I know, but I’m not that familiar with editline and such.
[1] https://github.com/asterisk/asterisk/blob/master/main/asterisk.c
—
Joshua C. Colp Digium – A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW – Huntsville, AL 35806 – US
Check us out at: http://www.digium.com & http://www.asterisk.org
—
thanks! That is exactly what I was looking for.
In case anybody else finds the default behavior annoying, here are couple of rules that make the CLI behavior more friendly:
# cat /etc/editrc
bind “^W” ed-delete-prev-word
bind “\e[1;5D” vi-prev-word
bind “\e[1;5C” vi-next-word
bind ^[[5~ ed-search-next-history
bind ^[[6~ ed-search-prev-history
so far, I was not able to find how to bind ctrl+d to exit.
—