tags:

views:

1931

answers:

3

I see some one demo git on Mac OS X on line. He can configure his Mac OS X terminal to have multiple color.

for example, his prompt is 'wheat' color, his ls directory is purple color. And his 'git diff' output can have ~ 4 colors (pink, light green, red, pale yellow)

Can you please tell me how can I configure Mac OS X terminal to achieve that. I am sure it is Mac OS X terminal, not iTerm.

+5  A: 

It is not normally something you configure the terminal to do... The terminal is unaware of what it is showing but try this in your shell (if you're using bash, in some other shells you don't export but call setenv or something else):

export CLICOLOR=1
export TERM=xterm-color

You can then use LSCOLORS generator to setup something that you can export using something like:

export LSCOLORS=fxfxcxdxbxegedabagacad

(the above should give you purple directories)

When you're done and satisfied with the result, add the three lines to either your /etc/bashrc or the .bashrc file in your user's home directory.

Edit: Also, in your terminal, make sure the checkbox "Display ANSI colors" (on the "Text" page) is checked.

Fredrik
.bashrc works too? On my mac it's .bash_profile, I know it's .bashrc on Linux but I figured it was different on mac with the whole BSD thing (Also LSCOLORS is different on Linux and BSD/Mac, it seems).
Jorge Israel Peña
.bashrc works for me... And yes, it is different. gls uses LS_COLORS (which can also be generated using the page linked to)
Fredrik
Thanks. But how can one configure to colors like 'wheat' ,'purple' in the prompt or ls output?or 'pink' in the 'git diff' output.Thank you.
yinglcs
The possible colors are the one you can find at the site I linked to, it is part of the standard and when they defined it you were happy if you had a terminal capable of showing 16 colors.
Fredrik
A: 

For colored ls output I would recommend installing the gnu coreutils and using that version of ls instead. For either version of ls you'll need to pass the correct flag to it, which is --color for the gnu version or -G for the standard OS X version. So you can do something like

alias ls='ls --color'

in your .bashrc.

To color your prompt you'll need to use the correct colors codes for your terminal, but mine uses

PROMPT="$(print '%{\e[0;38m%}%{\e[1;1m%]%}[%m:%c] %n%%%{\e[0m%}') "

to produce

[hostname:directory] username%

in bold white.

Amuck
+4  A: 

To display color in the output of git diff, you need to configure git. Try running 'git config --global color.diff true' to set your $HOME/.gitconfig appropriately.

William Pursell
William, Yes! This is what I was missing.
Alessandro Vernet