LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 04-24-2005, 08:24 AM   #1
richiangpan9
LQ Newbie
 
Registered: Apr 2004
Location: Washington, DC
Distribution: RedHat Linux Professional Workstation
Posts: 4

Rep: Reputation: 0
help! bash command prompt font/color change


can anyone please help me? i'm a newbie trying to figure out linux files and bold or colored command prompts would stand out a lot! my current command prompt is
PS1=' \h \u \w \#> ' .
how can i show the prompt in BOLD or in a different COLOR? thank you for a fast reply!
richard in washington, dc
 
Old 04-24-2005, 09:12 AM   #2
Oliv'
Senior Member
 
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014

Rep: Reputation: 36
Hello,

see the bash prompt Howto for a complete explanation
 
Old 04-24-2005, 09:16 AM   #3
hussar
Member
 
Registered: Oct 2003
Location: Heidelberg, Germany
Distribution: Slackware 11.0; Kubuntu 6.06; OpenBSD 4.0; OS X 10.4.10
Posts: 345

Rep: Reputation: 30
You can put colors into your bash prompt using ANSI escape sequences. How to do it is described pretty clearly in the Bash-Prompt-HOWTO which is available at www.tldp.org or, depending on your distribution, in /usr/packages/doc/.

Basically, the sequence for your bash prompt in blue looks like this:

PS1="\[\033[1;34m\]\[\h \u \w \]#>\[\033[0m\] "

I think I got that right. Try it and see how it works for you. You can just start up an xterm and paste that in at the command line. The prompt should change immediately. It will go away when you exit the xterm.
 
Old 04-24-2005, 11:34 AM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Put this in your .bashrc (or edit to suit your needs first). If you are logged in as user, the prompt is blue. If you su to root, the prompt changes to red. The prompt also shows the full path to the directory you are currently in.

# bash-specific settings
ROOT_UID=0
if [ "$UID" -eq "$ROOT_UID" ]
then
PS1="\[\033[31;1m\]\u \d] \\$\w\n \[\033[0m\]"
else
PS1="\[\033[34;1m\]\u \d] \\$\w\n \[\033[0m\]"
fi
 
  


Reply



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 font color xterm aeruzcar Linux - Software 3 01-04-2012 04:48 PM
Command Prompt Color init_linux Linux - General 2 09-08-2005 02:20 AM
change the font color Drunkalot Linux - General 2 08-09-2005 10:37 PM
change the console font color minike Slackware 3 08-30-2004 05:11 PM
change font color...no NOT in X centr0 Slackware 4 05-01-2003 03:29 AM

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

All times are GMT -5. The time now is 01:48 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