Enabling colour in xterm under X11 and editing bash environment for X11

Hi I was just wondering if someone could help me in determining what I need to add into my .bash_profile in order to enable colour in the xterm, ie so that when ls is used it color codes the different file types and directories as most unix terminals would do. As well if it is not a .bash_profile file that I need to edit my bash environment what file is needed?

MacBook Pro, Mac OS X (10.4.8), 1.83 GHz Intel Core duo

Posted on Jan 24, 2007 11:05 AM

Reply
7 replies

Jan 24, 2007 6:22 PM in response to Novadan

Hi Novadan,

In order to get color output from ls command, you need to set CLICOLOR

export CLICOLOR=

CLICOLOR can be set to any value (including null string, as above). You may put this line to your .bashrc.

If you still don't get color output, then you must also set TERM to xterm-color (may other color-capable terminals may also work). You can do this by adding

export TERM=xterm-color

to .bashrc. Another method is to add the following line to your ~/.Xdefaults

XTerm*termName: xterm-color

PowerMacG4, PowerBookG4, iMac(C2D) Mac OS X (10.4.8)

Jan 25, 2007 6:42 PM in response to Jun T.

Thanx for this info. I was aware that Darwin's "ls" doesn't colorize the same way as Linux versions do, but didn't know they could do it at all.

BTW, it's more typical to put your export statements in your .bash_profile file so that they aren't redundantly executed for each new shell level.

Finally, for more information, see the ls man page: % man ls

iMac G4 Mac OS X (10.4.8)

Jan 25, 2007 9:40 PM in response to Ken Nellis

it's more typical to put your export statements in your .bash_profile


Yes, it may be more "typical". But on MacOSX, by default, Apple's X11 invokes xterm without the -ls option, so the shell running in the xterm window is not a login shell. As you know, a login bash reads only .bash_profile while non-login bash reads only .bashrc. So CLICOLOR must be set in .bashrc (unless you configure your X11 so that xtem starts a login shell, by editing .xinitrc or .Xdefaults).

In theory, .bash_profile is for the top level (login) shell, and .bashrc is for sub-shells. But I guess may bash users make their .bash_profile to have just one line

source .bashrc



PowerMacG4, PowerBookG4, iMac(C2D) Mac OS X (10.4.8)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Enabling colour in xterm under X11 and editing bash environment for X11

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.