CLI Color Prompt
Hello,
how can I change the color of the asterisk prompt to red ?
I read in the wiki that I can use %Cn[;n]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+CLI+Configuration
But what does this mean ?
There is no example how to actually use it. where do I put it?
What syntax is that anyway?
How do I specify red ?
I currently have this in my environment:
export ASTERISK_PROMPT=”[%H]: ”
which changes the prompt to hostname
Ho can I make this prompt red ?
thanks,
—
17 thoughts on - CLI Color Prompt
Have you tried adding ANSI color escape codes?
There’s lots of documentation for BASH prompt color using escape codes. Give those a try.
(I haven’t tried it, but would make sense)
—–Original Message—–
From: asterisk-users [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Fourhundred Thecat Sent: Sunday, May 31, 2020 9:45 AM
To: asterisk-users@lists.digium.com Subject: [asterisk-users] CLI color prompt
Hello,
how can I change the color of the asterisk prompt to red ?
I read in the wiki that I can use %Cn[;n]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+CLI+Configuration
But what does this mean ?
There is no example how to actually use it. where do I put it?
What syntax is that anyway?
How do I specify red ?
I currently have this in my environment:
export ASTERISK_PROMPT=”[%H]: ”
which changes the prompt to hostname
Ho can I make this prompt red ?
thanks,
—
“The CLI prompt is set with the ASTERISK_PROMPT UNIX environment variable that you set from the Unix shell before starting Asterisk.”
“%Cn[;n] – Change terminal foreground (and optional background) color to specified A full list of colors may be found in include/asterisk/term.h”
So, try:
export ASTERISK_PROMPT=”%C31[%H]: ”
(I got 31 from reading the term.h file.)
Regards,
Antony.
—
“It would appear we have reached the limits of what it is possible to achieve with computer technology, although one should be careful with such statements;
they tend to sound pretty silly in five years.”
– John von Neumann (1949)
Please reply to the list;
please *don’t* CC me.
—
> thanks, but that does not work for me. When I use your example:
export ASTERISK_PROMPT=”%C31[%H]: ”
I get this prompt (voip is my hostname):
[1;31m[voip]: [1;0m
—
In that case I suspect you’re using a terminal which doesn’t support colours.
If “echo $TERM” tells you any sort of “xterm”, “vt100”, “crt” or “dumb” then you won’t get colour.
Regards,
Antony.
—
Late in 1972 President Richard Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used a third derivative to advance his case for re-election.
– Hugo Rossi, Notices of the American Mathematical Society
Please reply to the list;
please *don’t* CC me.
—
I’m pretty sure that means your are using a non-color capable terminal, or your termtype variable is incorrect. What are you using for a terminal emulator?
*Jeff LaCoursiere*
STRATUSTALK, INC. / CTO
Phone: *+1 703.496.4990 x108*
Mobile: *+1 815.546.6599*
Email: *jeff@stratustalk.com*
Website: *https://www.stratustalk.com*
Address: *
> my terminal definitely supports colors. I am using colored prompt in bash/zsh.
echo $TERM gives me:
xterm-256color
—
> my terminal supports colors, I am using colored prompt in bash/zsh already. I made a screenshot:
https://paste.pics/d1eb46bac0a8d06d645230225191615e
—
That means that Asterisk is not echoing the escape character (27) to your terminal.
Try different escape formats (octal, slash prefix, etc)
—–Original Message—–
From: asterisk-users [mailto:asterisk-users-bounces@lists.digium.com] my terminal supports colors, I am using colored prompt in bash/zsh already. I made a screenshot:
https://paste.pics/d1eb46bac0a8d06d645230225191615e
—
can somebody please provide working example ?
What exactly to I have to export?
—
does this work for you?
Did you test it on your side?
It color prompt works for anybody, could you please post a working example?
Or is this a fictional functionality that actually does not work ?
—
Hello Fourhundred,
Sunday, May 31, 2020, 9:04:10 AM, you wrote:
Fourhundred> Did you test it on your side?
Fourhundred> It color prompt works for anybody, could you please post a working example?
Fourhundred> Or is this a fictional functionality that actually does not work ?
I typed this at the terminal prompt: export ASTERISK_PROMPT=”%C31[%H]: ”
Typing at the same place: echo $TERM returns xterm
And now I have colored prompts at the Asterisk command line, so I can assure you it can work. Kind of cool, 14 years using Asterisk and because of your question, I now have colored prompts.
Do I have to do something to make sure that ASTERISK_PROMPT lives through a reboot?
— Ira
—
I would add the export to .bashrc/.zshrc or whatever shell you are using
why does it not work for me?
My terminal clearly supports 256 colors.
—
Hi,
I had posted this a few hours ago, but got caught in moderation for size. I trimmed down the pic and attached.
I am on an Ubuntu 16 workstation, in an Ubuntu terminal window, ssh’ed to the PBX (amazon instance). You can see my term type matches yours.
I really don’t know why yours doesn’t work. Perhaps you can tell us what your terminal emulator is, what you are running it on, etc.
Whatever it is, it isn’t properly interpreting the escape codes for xterm-256color. You could possibly try some different terminal types, but this is an odd situation if the remote shell (is it remote?) can’t determine your termtype. This is pretty ancient code.
j
*Jeff LaCoursiere*
STRATUSTALK, INC. / CTO
Phone: *+1 703.496.4990 x108*
Mobile: *+1 815.546.6599*
Email: *jeff@stratustalk.com*
Website: *https://www.stratustalk.com*
Address: *
> my terminal emulator is terminator, I also tried xterm (same result)
and echo $TERM gives me:
xterm-256color
My system is Debian Buster, but not sure if that is relevant
what terminal emulator are you using ?
—
Same problem here (asterisk 16.x / CentOS 7).
# echo $TERM
xterm-256color
=> CLI prompt looks the same as described by the OP:
[1;31m[myhostname]:
But to make it even more strange: colored output on the asterisk CLI works pretty fine for DEBUG output like core set debug 5
Maybe some link time functionality not enabled? Don’t know … . Or some other additional asterisk switch needed?
Thanks Regards Michael
—
> I am using asterisk 16.x as well, on Debian Buster.
exactly. The error/debug messages appearing in CLI are colored.
Which of the components cases this problem?
a) asterisk b) terminal emulator c) or the OS/environment
How can I troubleshoot this problem ?
—
I work from a similar setup. I ssh’ed to my personal PBX from an xterm window on an Ubuntu 16 workstation, your prompt seems to work:
*Jeff LaCoursiere*
STRATUSTALK, INC. / CTO
Phone: *+1 703.496.4990 x108*
Mobile: *+1 815.546.6599*
Email: *jeff@stratustalk.com*
Website: *https://www.stratustalk.com*
Address: *