LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-29-2012, 02:08 AM   #1
hamidi2
Member
 
Registered: Aug 2012
Posts: 63

Rep: Reputation: Disabled
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
 
Old 08-29-2012, 02:28 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
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.
 
1 members found this post helpful.
Old 08-29-2012, 05:44 PM   #4
casualfred
Member
 
Registered: Aug 2012
Location: Kentucky, USA
Distribution: Slackware
Posts: 97

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

http://www.ibm.com/developerworks/li.../l-tip-prompt/
 
1 members found this post helpful.
Old 08-29-2012, 11:26 PM   #5
hamidi2
Member
 
Registered: Aug 2012
Posts: 63

Original Poster
Rep: Reputation: Disabled
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.
 
Old 08-29-2012, 11:29 PM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Hi,

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

Cheers,

Evo2.
 
1 members found this post helpful.
Old 08-30-2012, 02:32 AM   #7
hamidi2
Member
 
Registered: Aug 2012
Posts: 63

Original Poster
Rep: Reputation: Disabled
thx
 
Old 08-31-2012, 11:46 PM   #8
hamidi2
Member
 
Registered: Aug 2012
Posts: 63

Original Poster
Rep: Reputation: Disabled
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.
 
Old 09-01-2012, 08:11 AM   #9
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
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.
 
Old 09-01-2012, 10:28 AM   #10
hamidi2
Member
 
Registered: Aug 2012
Posts: 63

Original Poster
Rep: Reputation: Disabled
sorry, couldn't figure out what u mean. it was about 1 or 2?
 
Old 09-01-2012, 11:44 AM   #11
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
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.
 
Old 09-01-2012, 11:35 PM   #12
hamidi2
Member
 
Registered: Aug 2012
Posts: 63

Original Poster
Rep: Reputation: Disabled
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change command line color fatherwillow Linux - Newbie 5 06-01-2012 07:27 AM
Command line prompt has changed une Linux - Newbie 3 09-19-2006 11:51 PM
Command Prompt Color init_linux Linux - General 2 09-08-2005 03:20 AM
help! bash command prompt font/color change richiangpan9 Linux - Newbie 3 04-24-2005 12:34 PM
ls command line, color and wildcards ioio85 Linux - Newbie 1 05-13-2004 06:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration