[Home]

Summary:ASTERISK-01263: [patch] Custom CLI prompt
Reporter:Tilghman Lesher (tilghman)Labels:
Date Opened:2004-03-22 00:23:30.000-0600Date Closed:2008-01-15 14:49:02.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20040323__custom_prompt.diff.txt
Description:Allows the CLI prompt to be customized via an environmental variable.
Comments:By: James Golovich (jamesgolovich) 2004-03-22 00:36:30.000-0600

Looks good to me.  My first thought was why use an environment var oposed to something in a config file, but after discussing on irc I see the light now.

I'm sure there are some other vars we can make available, right now the only one that comes to mind is pid (maybe one for current pid and another for master asterisk pid)

Maybe other people can add bugnotes about what they would like to see available to this namespace

By: Olle Johansson (oej) 2004-03-22 04:05:05.000-0600

Is it possible to add environment variable support? I have a variable for number of PSTN calls.

Uptime is always interesting

\n for newline is a good choice.

To take it far too long, some color/highlight support would be good, would make the console easier to read (or not, but that's up to the user :-) )

By: Tilghman Lesher (tilghman) 2004-03-22 10:47:45.000-0600

You're going to have to explain what you mean by "environment variable support".  Isn't that what this patch already does?

Newlines are embeddable in the environmental variable.  However, this will break some assumptions inherent in the CLI, so the CLI won't be completely erased when new messages hit the console.

Color/highlight is already available:  just embed your control codes into the environmental variable.  As long as your control codes don't contain '%', it will work fine.

By: Olle Johansson (oej) 2004-03-22 11:01:22.000-0600

I would like to be able to embed a reference to a variable, so it gets updated each time the CLI prompt is printed.

Color highlight: WOuld be good to have short codes instead of having to lookup ansi colors. They're already somewhere within the code I guess.

By: Tilghman Lesher (tilghman) 2004-03-22 22:16:13.000-0600

The color codes aren't there, as such.  There's only encapsulation support, which is probably not what you want.  See term.c.

I've now added %# for prompt changes (# for root console, > for remote console) and %l1 through %l5 (that's a lowercase-L, as in loadavg).  l1 is 1 minute loadavg, l2 is 5 minute loadavg, l3 is 15 minute loadavg, l4 is the fraction, and l5 is the next process number (see /proc/loadavg).  I've also added %%, which prints a literal %.

By: slepp (slepp) 2004-03-23 12:39:25.000-0600

What about %d for the date (D/M/Y format?), perhaps 'localhost' isn't the real best option if the gethostname() doesn't work, and the uptime I imagine could be implemented with a static time_t even within the CLI part, where we just set it on the first prompt draw and then use that difference from start time to now (formatting it into something useful is the only bit that's more than 4 lines).

By: James Golovich (jamesgolovich) 2004-03-23 13:57:15.000-0600

We don't want to go overboard with adding things to this.  IMO only things that aren't easily available elsewhere should go into this.

Remember that this will be executed whenever the prompt is printed, so too much activity could negatively impact asterisk

By: Tilghman Lesher (tilghman) 2004-03-24 16:41:57.000-0600

I think this one is ready to go.

By: James Golovich (jamesgolovich) 2004-03-26 00:02:43.000-0600

Commited to CVS HEAD

By: Digium Subversion (svnbot) 2008-01-15 14:49:02.000-0600

Repository: asterisk
Revision: 2565

U   trunk/asterisk.c

------------------------------------------------------------------------
r2565 | citats | 2008-01-15 14:49:02 -0600 (Tue, 15 Jan 2008) | 3 lines

Allow CLI Prompt to be customizable via ASTERISK_PROMPT environment
variable (bug ASTERISK-1263)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=2565