Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
TIP: Custom text colors per tty (for splash, etc)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Nate_S
Guru
Guru


Joined: 18 Mar 2004
Posts: 414

PostPosted: Sun Sep 25, 2005 8:39 pm    Post subject: TIP: Custom text colors per tty (for splash, etc) Reply with quote

The color of the text you type is controlled by the PS1 enviromental variable. This is normally set up by /etc/bash/bashrc. I wanted a way to customize the text color for each tty (as I was using a custom splash screen per tty, and some of them (NightWorld) were hard to read with the default grey text due to low contrast, and I thought green text would be very fitting with the Matrix Theme,) so I set up this script:

Code:

if [[ ${TERM} == "linux" ]] ; then
        if [[ ${EUID} == 0 ]] ; then
                if [[ $(tty) == "/dev/tty2" ]] ; then
                        PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00;35m\] '
                elif [[ $(tty) == "/dev/tty3" ]] ; then
                        PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[01;32m\] '
                elif [[ $(tty) == "/dev/tty4" ]] ; then
                        PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00;31m\] '
                elif [[ $(tty) == "/dev/tty5" ]] ; then
                        PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[01;36m\] '
                elif [[ $(tty) == "/dev/tty6" ]] ; then
                        PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00;32m\] '
                else
                        PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
                fi
        else
                if [[ $(tty) == "/dev/tty2" ]] ; then
                        PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00;35m\] '
                elif [[ $(tty) == "/dev/tty3" ]] ; then
                        PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[01;32m\] '
                elif [[ $(tty) == "/dev/tty4" ]] ; then
                        PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00;31m\] '
                elif [[ $(tty) == "/dev/tty5" ]] ; then
                        PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[01;36m\] '
                elif [[ $(tty) == "/dev/tty6" ]] ; then
                        PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00;32m\] '
                else
                        PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
                fi
        fi
fi


I called it /etc/termcolors and then added the line 'source /etc/termcolors' to the bottom of /etc/bash/bashrc. More info on PS1 variables, as well as a table of all the color codes you can use for it, is available here: http://www.gentoo.org/doc/en/articles/prompt-magic.xml

-Nate
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum