LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   910608 - command line prompt in color (https://www.linuxquestions.org/questions/linux-newbie-8/910608-command-line-prompt-in-color-4175424527/)

hamidi2 08-29-2012 01:08 AM

910608 - command line prompt in color
 
hi
they used to hit enter and insert multiple empty prompt lines to separate between different command executions. in DOS we used to change the command line color by using prompt command, like:
prompt $e[1;3$p$g
is there such a capability in Linux to change color of command prompt?
thx

evo2 08-29-2012 01:28 AM

Hi,

yes assuming you are using bash (or similar), you can change your prompt (including the color) by changing the PS1 environment variable.

Putting "bash PS1 color howto" into a decent search engine will provide you with plenty of useful resources.

Evo2.

Habitual 08-29-2012 03:10 PM

Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
http://www.gnu.org/software/bash/man...ode/index.html
http://www.grymoire.com/Unix/Sh.html
http://www.tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/BashFAQ
http://mywiki.wooledge.org/BashPitfalls
Stole this function from unSpawn

casualfred 08-29-2012 04:44 PM

I thought this was a very useful guide, shows you how to do colors too..

http://www.ibm.com/developerworks/li.../l-tip-prompt/

hamidi2 08-29-2012 10:26 PM

thank u all very much.
i use putty to telnet to server. how can i make the change permanent? i mean every time i login to server i get the same prompt i've defined.

evo2 08-29-2012 10:29 PM

Hi,

you can put it in your ~/.bashrc file which is automatically sourced for interactive shells.

Cheers,

Evo2.

hamidi2 08-30-2012 01:32 AM

thx :)

hamidi2 08-31-2012 10:46 PM

1. i viewed .bashrc and found that it decides to use a colored prompt or not based on $color_prompt. it seems that it's an environment variable. how can i define the true value for the variable.
2. whenever i start my putty session, the font returns to Courier New. how can i make it use the last font specified? in another words, not to change it back to default and keep my last settings.

spiky0011 09-01-2012 07:11 AM

Hi

Do you mean when you connect to server it changes, if so I done mine so when I ssh in I changed the .bashrc on the server for the user so then it changes the prompt when connected. I hope this is what you mean.

hamidi2 09-01-2012 09:28 AM

sorry, couldn't figure out what u mean. it was about 1 or 2?

spiky0011 09-01-2012 10:44 AM

I was mentioning when you ssh into server. I have changed on the server .bashrc, so when I log into the server the prompt changes to what is set in server .bashrc, I have also been looking at how to change prompt when ssh into a server But have been unable to find a solution. Changing .bashrc on server was the only fix I found.

hamidi2 09-01-2012 10:35 PM

ok, so u mean using .bashrc is probably the only solution?
ok, i've no disagreement, and my question was a different thing. i'm going to use .bashrc and it seems that a colored prompt has been specified in it. but, (let me repeat my question) what's $color_prompt and how can i set it to true?
no idea about the second question?


All times are GMT -5. The time now is 08:31 PM.