Sensible Open Source

Changing Colors in the Linux Terminal

posted 7 November 2007, Wednesday

I guess I'm getting old because I just cant see BLUE (34) on BLACK.  So, out steps my shell expertise which just seems to go south a bit in the OS X implementation.

I remembered what to do in Linux but could not remember OS X.  So, the solutions for LINUX is first and OS X will follow in the next day or so as it is a little less straight forward:

LINUX

1. from the command execute dircolors -p > ~/.dirSourceJES (you can choose any name here I chose .dirSourceJESwhich is the COLOR setup for the ls command.  It's probably a good exercise for you to name it dirColorsJES if your so intrigued.  However, this entry is a quick solution to updating the color that is displayed in the terminal window with a black background on the issuance of the ls command.

Of course, look into the .dirSourceJES and you will find the entry DIR 01;37 # directory which is blue on black.  The quick fix is to change it to DIR 01;38 # directory. Save the file and get back to the shell.

vi .bashrc if it does not exist create it and if does add this to the bottom of the file: 

# User specific aliases and functions
alias ls='ls --color=auto'
eval "`dircolors -b ~/.
dirColorsJES`"

alias ls='ls --color=auto'
 
This forces ls to issue the colors switch ensuring the utilization of your color changes.

eval "`dircolors -b ~/.dirColorsJES`"

 NOTE:  Remember -b, -sh  is for the bourne shell code to set LS_COLORS. 

            For the C Shell -c,--csh, --c-shell to set LS_COLORS

This allows the shell on startup to engage your options, in this case the directory color option.  You can review this for your own study.

Once .bashrc is updated save it and exit the editor.  To immediately engage the changes into your shell simply use the source command as shown below:

source ~/.bashrc

Of source this is user centric.  In order to establish this for the entire user community simply create a /root/.dircolorsROOT file, create or edit a .bashrc and add the alias and eval statements and whala!! You're a UNIX guru.


tags:    

links: digg this    del.icio.us    technorati    reddit




1. Trim left...
5 December 2007, Wednesday 10:12 am

This was very helpful and did exactly what I wanted - Thank you! =o) 05/12/07


2. Chris N left...
29 December 2008, Monday 3:54 pm

Awesome! Looked everywhere for a solution!


3. sanoja left...
21 July 2009, Tuesday 4:56 pm

Excellent! I am 'old' too and the black in blue was driving me nuts. Thank you!


4. Atif left...
22 March 2010, Monday 9:44 pm

Superbbbb


5. Rach. S left...
12 March 2012, Monday 8:23 am

Thanks a Lot ! direct explanation.