Click to Play

Google Spices Up Enterprise...
Along with the HTML5 and Google TV announcements at Google I/O, there were also several that pertained to business, involving enterprise and...

Recent Articles

Is It Time For OpenSolaris Users To Jump Ship?
Since Oracle acquired Sun Microsystems and with it, several open source technologies, OpenSolaris users want to know where Oracle's priorities lie. OpenSolaris has had three stable releases in approximately six...

BitDefender Rolls Out Antivirus Scanner For UNIX
In many organizations UNIX-based workstations are becoming popular as a cost effective computing resource. As UNIX-based endpoints become easier...

Fork Bomb Protection
The fork command is a vital part of the Unix shell environment. It works by creating a new thread, called the child, which is identical to the original (parent) thread. From there the new thread will execute the ...

Where Does The IT Community Stand Now...
While Novell's ownership of Unix was confirmed by a jury earlier this week, Novell's future as an independent company, at least in its current form, is far from secure.

SCO Group Receives $2 Million In Financing
For better or for worse - and admittedly, many people will say it's for the much, much worse - the SCO Group has received a financial lifeline of sorts. SCO, which filed for Chapter 11 bankruptcy protection in 2007, is set...


06.01.10



How To Setup Gentoo Style Colors For Bash On Your Linux/Unix System

By Alex Trent

This Linux/Unix tutorial will show you how to colorize your Bash prompt to resemble the colors of Gentoo Linux is easier than you think.

First, see if the default shell is thebash shell with the command:
env | grep SHELL=
This should report something like:
SHELL=/bin/bash

If you see that or/usr/bin/bash, you're good to go. If bash is not your default shell you can see if its installed by just typing bash. If bash is installed, you can make it your default shell by typingchsh -s /bin/bash. Make sure you use the correct path for bash by checking for it in/etc/shells. If bash is not available on your system, try using your package manager to install it or consulting the OS manual.

Next, add the color prompt to.profile or on most linux systems add it to.bashrc.
if [[ ${EUID} == 0 ]] ; then
        PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
        PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi

If your.profile or.bashrc already has a line that begins with PS1, like the lines above you may just want to comment out that line by putting a '#' symbol at the beginning and pasting one of the lines beginning with 'PS1' above on a new line right below the line you commented out.


Take note of the values in the second pair of brackets [01;31m\]. The number before them is where you set the color of the prompt. The default is to use 31 (red) for root (this is why the code above checks if the user id (EUID) is 0, the root user id) and 32 (green) for all other user accounts. But you can use any color you like.

I've compiled a short list of the available colors I found below:
30 = grey
31 = red
32 = green
33 = yellow
34 = blue
35 = pink
36 = cyan
37 = white

Once you've set the color, login to another console or open another copy of your favorite terminal emulator to see the results.

You can also use the file colors used by Gentoo. Grab a copy of the Gentoo DIR_COLORS file http://tinderbox.dev.gentoo.org/misc/DIR_COLORS. Now check if your .bashrc or.profile scripts are already checking for a .dir_colors file or a.dircolors file. If you find this is true then all you have to do is copy DIR_COLORS to .dir_colors or.dircolors and thats it.

If your.bashrc or.profile are not looking for the .dir_colors or.dircolors file, then add the functionality yourself with:
if type -P dircolors>/dev/null ; then         if [[ -f ~/.dir_colors ]] ; then
            eval $(dircolors -b ~/.dir_colors)
        elif [[ -f /etc/DIR_COLORS ]] ; then
            eval $(dircolors -b /etc/DIR_COLORS)
        fi
fi
alias ls='ls --color=auto'

For BSD Unixes you might have to add: export CLICOLOR=1 LSCOLORS="ExGxFxDxCxDxDxhbhdacEc" to your.bashrc or.profile.


About the Author:
Alex Trent is a staff writer for WebProNews
About UnixProNews
UnixProNews is a collection of news and commentary designed to keep you in step with the ever evolving landscape of Unix environments. News and Advice for Unix Professionals
iEntry





UnixProNews is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITCertificationNews.com






-- UnixProNews is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2010 iEntry, Inc. All Rights Reserved Privacy Policy Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


News and Advice for Unix Professionals UnixProNews News Archives About Us Feedback UnixProNews Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact