LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Configuring terminal colors (the original BASH shell!) (https://www.linuxquestions.org/questions/linux-software-2/configuring-terminal-colors-the-original-bash-shell-582511/)

lectraplayer 09-05-2007 07:48 PM

Configuring terminal colors (the original BASH shell!)
 
I remember being able to configure the colors of my BASH terminal (outside of X), but am trying to remember how I did it. Seems like it was something like set term -background white -foreground red as one example, and with the same command stopping the screen from blanking with something like set term -blank 0 or something to that effect. Now, for the life of me, I seem to be having difficulty pulling it off. I dug up where someone mentioned that it was setterm -blank 0, but that proved to be incorrect. The man pages I've stumbled across are getting me no closer. What was the command again? I like to beat commands into Linux outside of X occasionally. Some things are actually easier and work better away from X.

SlowCoder 09-05-2007 07:51 PM

Here's a little script I wrote not too long ago. Add it to your .bashrc

Code:

#Color Codes:
#Black      0;30    Dark Gray    1;30
#Red        0;31    Light Red    1;31
#Green      0;32    Light Green  1;32
#Brown      0;33    Yellow        1;33
#Blue        0;34    Light Blue    1;34
#Purple      0;35    Light Purple  1;35
#Cyan        0;36    Light Cyan    1;36
#Light Gray  0;37    White        1;37
 
PROMPTCOLOR='\[\e[1;37m\]'
COMMANDCOLOR='\[\e[0;37m\]'
ROOTCOLOR='\[\e[1;31m\]'
NORMALUSERCOLOR='\[\e[1;32m\]'
HOSTNAMECOLOR='\[\e[1;35m\]'
DIRECTORYCOLOR='\[\e[1;33m\]'
 
### username ###
if [ `whoami` = "root" ]
        then USERCOLOR=$ROOTCOLOR
        else USERCOLOR=$NORMALUSERCOLOR
fi
PS1=$USERCOLOR"\u"
 
### hostname ###
PS1=$PS1$PROMPTCOLOR@
PS1=$PS1$HOSTNAMECOLOR$(hostname -s)
 
### working directory ###
PS1=$PS1$PROMPTCOLOR" ["
PS1=$PS1$DIRECTORYCOLOR"\w"
PS1=$PS1$PROMPTCOLOR"]"
 
### prompt end marker ###
PS1=$PS1$USERCOLOR" \$ "
 
### command color ###
PS1=$PS1$COMMANDCOLOR

Oh, and let me know what you think. :)

lectraplayer 09-05-2007 08:06 PM

Thanks! ;) ...though I remember doing it with a command, and then putting it in /etc/profile to make it permanent. I was also hoping to put a stop to it blanking out, for example if I'm reading a page full of text in less (and no, I cannot read faster! ).


All times are GMT -5. The time now is 02:42 AM.