cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1081
Views
5
Helpful
6
Replies

How to set CLI prompt colour?

u.avsec
Spotlight
Spotlight

Hey.

 

I'm trying to change NSO CLI prompt colour. I'm using this thread as help: https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux

 

In my linux shell this prints following text green:

printf '\033[32m'

 echo $TERM prints 'xterm'

 

I tried the following in ncs.conf (ncs --reload applied):

<cli>
    <c-prompt1>\033[32m\u@ncs#\033[0m </c-prompt1>
    <c-prompt2>\[\033[32m\]\u@ncs(\m)#\[\033[m\] </c-prompt2>
</cli>

Nothing, CLI prints 033[ and stuff instead of colours. I tried with 'e' instead of '033' too. No music.

 

Tail-f, please help

6 Replies 6

vleijon
Cisco Employee
Cisco Employee
This command works for me: "\e[38;5;9mNSO\e[0m \u@\h#”

I don't have such luck:

Capture.JPG

I used your example, the user and hostname flags work, but colour stuff not.

 

This is on Windows Terminal, I tried with putty just in case, to same result.

It works in the CLI, which is where I always do it:

 

ss.jpeg

 

Not sure if you need to do something special in ncs.conf.

That was it, I was setting it up in ncs.conf and it just doesn't want to work.

 

How do I persist the prompt change done via CLI though?

 

You can set it as config under user admin session prompt1, but I am not entirely sure what the correct escaping would look like, maybe someone else knows.

I tried combinations of what I found as an example in man pages:

<prompt1>\[&#x1b;]0;\u@\h&#x07;\]\u@\h&gt; </prompt1>

This this particular expression works. When I tried to apply it for colour coding it doesn't. Either because I might be misreading the example or because it simply doesn't want to do colours.