Re: Adding Color / colour to my prompt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Paul Ward wrote:
> Hello,
> 
> I want to have a promt that changes colour depending on the user that
> logs in.
> 
> I have added the following to the /etc/skel.bashrc and my other users
> .bashrc files.
> 
>   if [ "$USER" == "root" ]; then
>     PS1="\[\033[0;31m\]\u@\h:\w\\$\[\033[0;37m\] "
>   else
>     PS1="\[\033[0;32m\]\u@\h:\w\\$\[\033[0;37m\] "
>   fi
> 
> this works great through putty but when using a gui the font changes
> to grey which is hard to read, this is due to the ansi color 37m, how
> can I add a check to see if I am using a putty terminal session or an
> X terminal session?
> 
> Any one got any other great tips for changing the prompt?
> 
> Paul
> 
You may want to create/edit /etc/sysconfig/bash-prompt-xterm for the
xterm colors, /etc/sysconfig/bash-prompt-screen for the colors used
by screen, and /etc/sysconfig/bash-prompt-default for the default
colors. Take a look at /etc/basrc for how they are used.

I would think something like this would work for bash-prompt-default:

   if [ "$USER" == "root" ]; then
     echo -e "\[\033[0;31m\]\u@\h:\w\\$\[\033[0;37m\] "
   else
     echo -e "\[\033[0;32m\]\u@\h:\w\\$\[\033[0;37m\] "
   fi

/etc/bashrc also shows you how to test for terminal type...

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux