5

I recently upgraded to Lion only to find that Terminal.app (and iTerm2, which I actually use instead) have totally lost all colors. This means no syntax highlighting in Vim, no colored directory names or filenames, no nothing. I've tried playing around with the terminal-type option in the preferences (for both apps), changing it to xterm-256color, xterm-new, xterm, etc. but all to no avail.

However! When I SSH into a remote machine in Terminal.app, I get colors! Everything works as it once did. Although this isn't the same with iTerm2, where I'm still left colourless.

3
  • I've been able to get the prompt to have colors by adding code to the ~/.profile file, but I'm not sure where the code for the folders goes. I only do this once a year or so... This didn't work for me, maybe you? blog.toddwerth.com/entries/13
    – skub
    Jul 31, 2011 at 0:03
  • If when you state "I'm not sure where the code for the colors go" you mean LSCOLORS, then maybe you should check out softwaregravy.wordpress.com/2010/10/16/ls-colors-for-mac. I'm assuming that you mean the colors for when you perform an ls on a directory and you see different files and folders, and you are wanting to change the color of the folder. Jul 31, 2011 at 1:49
  • I added some info to that effect supplemental to my first answer.
    – skub
    Jul 31, 2011 at 20:08

3 Answers 3

7

I had to edit ~/.profile and put this code in to make folders color.

export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

This shows LSCOLORS options.

I used this to make a custom cursor:

PS1='\[\033[01;32m\]\u@macair\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Hope this helps.

For vim, use a theme like this theme

And add 2 folders, ~/.vim and ~/.vim/colors

Put the theme file in your ~/.vim/colors folder

Then make a file called ~/.vimrc with something like this:

syntax on        'this is needed to see syntax
set background=dark  "makes it easier to read with black background
colorscheme ir_black "set theme in ./vim/colors folder
set ls=2            " allways show status line
set hlsearch        " highlight searches
"set incsearch       " do incremental searching
set ruler           " show the cursor position all the time
set visualbell t_vb=    " turn off error beep/flash
set ignorecase        "ignore case while searching
set number            'put numbers on side

I've added comments so you can pick and choose what you want. Also, I ended up tweaking the theme. It made comments grey and they were too hard to read.

4
  • This partially works and does show colours when doing an ls for example. Still no coloring anywhere else in the shell though (e.g. in Vim)
    – ajackbot
    Jul 31, 2011 at 11:25
  • You have to add the colors to vim the same way. I just did it. You need folder ~/.vim/colors/whatevertheme.vim and you need a ~/.vimrc file that specifies that you want to use the whatevertheme.
    – skub
    Jul 31, 2011 at 13:58
  • This doesn't work either - Vim is reading the colors file but I'm still getting a monochrome terminal. I still get full colours when SSHing into another machine though :/
    – ajackbot
    Aug 1, 2011 at 8:23
  • Actually, after much playing around it turned out the LSCOLORS option was the key. Thanks!
    – ajackbot
    Aug 1, 2011 at 9:58
2

You need add these settings on your .vimrc

filetype on
filetype plugin on
filetype indent on
syntax on

To enable your color highlighting.

I was using my .vimrc, which does not have these, but works in Linux and old OS X versions. For Lion, you need add them.

2

I have the following in my ~/.profile

function parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\*\1/'
}

case "$TERM" in
  xterm-*color) color_prompt=yes;;
esac


if [ "$color_prompt" = yes ]; then
    PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[0;33m\]$(parse_git_branch)\[\033[00m\]\$ '
else
    PS1='\u@\h:\w$(parse_git_branch)\$ '
fi
1
  • This is amazing!
    – Parris
    Nov 30, 2012 at 8:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .