LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   help! bash command prompt font/color change (http://www.linuxquestions.org/questions/linux-newbie-8/help-bash-command-prompt-font-color-change-316641/)

richiangpan9 04-24-2005 08:24 AM

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

Oliv' 04-24-2005 09:12 AM

Hello,

see the bash prompt Howto for a complete explanation

hussar 04-24-2005 09:16 AM

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.

bigrigdriver 04-24-2005 11:34 AM

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


All times are GMT -5. The time now is 03:05 AM.