Make your Leopard Terminal (and VIM) shine with SIMBL, TerminalColors, and the IR_black theme

May 8, 2008

One thing that always bothered the crap out of me about OS X was their implementation of 'Terminal'. Staring at a black box with only white text is quite unnerving. I'm not sure how their seemingly graphically-inclined designers at Apple could handle it. Anyways, there's fortunately an easy solution to this ginormous problem.

There's an excellent tutorial that runs through the process of customizing just about everything with Terminal, but I'm going to get right to the point with as little extra stuff as possible.

The very first thing we need to do is actually enable colors in our Terminal. Pop open Terminal. You should automatically be at your home directory to start, but if you're not, just:

cd ~

Now we need to create a file titled .bash_profile. This file gets loaded every time you open a new Terminal session. Create a new file with VIM like so:

vim .bash_profile

and enter the following:

source ~/.bashrc

Save the file with :wq. Essentially, all this says is 'load a file called .bashrc'. Each user can have a .bashrc file. Create your .bashrc file:

vim .bashrc

and enter the following:

export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
alias ls='ls -G'
export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_RED='\e[0;31m'
export COLOR_LIGHT_RED='\e[1;31m'
export COLOR_PURPLE='\e[0;35m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_BROWN='\e[0;33m'
export COLOR_YELLOW='\e[1;33m'
export COLOR_GRAY='\e[1;30m'
export COLOR_LIGHT_GRAY='\e[0;37m'
alias colorslist="set | egrep 'COLOR_\w*'"

The above is what enables the colors for your terminal. Save the file.

You could now quit terminal, and start a new session, and you should have colors. The default colors aren't so nice, though. Luckily, a few quick plugins will allow us to customize the colors. Ciaran Walsh runs through these steps, or you an follow along below.

First, install SIMBL. Second, download Ciaran's SIMBL plugin. You can now quit terminal, restart, and you'll see a 'More' button in Terminal settings allowing you to customize your colors.

I personally use InfiniteRed's theme here.

So now everything is beautiful, except for VIM. I use VIM quite a bit throughout my day, so this is important for me. Luckily, there's a simple fix for this as well. Navigate to your home directory, and create the file '.vimrc', and enter the following code (or grab it from here):

" This .vimrc file should be placed in your home directory
" The Terminal app supports (at least) 16 colors
" So you can have the eight dark colors and the eight light colors
" the plain colors, using these settings, are the same as the light ones
" NOTE: You will need to replace ^[ with a raw Escape character, which you
" can type by typing Ctrl-V and then (after releaseing Ctrl-V) the Escape key.
if has("terminfo")
set t_Co=16
set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
else
set t_Co=16
set t_Sf=[3%dm
set t_Sb=[4%dm
endif
syntax on
" Everything from here on down is optional
" These colors are examples of what is possible
" type :help syntax
" or :help color within vim for more info
" and try opening the file
" share/vim/vim61/syntax/colortest.vim
" Note: where share is depends on where/how you installed vim
highlight Comment ctermfg=DarkGreen
highlight Constant ctermfg=DarkMagenta
highlight Character ctermfg=DarkRed
highlight Special ctermfg=DarkBlue
highlight Identifier ctermfg=DarkCyan
highlight Statement ctermfg=DarkBlue
highlight PreProc ctermfg=DarkBlue
highlight Type ctermfg=DarkBlue
highlight Number ctermfg=DarkBlue
highlight Delimiter ctermfg=DarkBlue
highlight Error ctermfg=Black
highlight Todo ctermfg=DarkBlue
highlight WarningMsg term=NONE ctermfg=Black ctermbg=NONE
highlight ErrorMsg term=NONE ctermfg=DarkRed ctermbg=NONE
" These settings only affect the X11 GUI version (which is different
" than the fully Carbonized version at homepage.mac.com/fisherbb/
highlight Comment guifg=Green gui=NONE
highlight Constant guifg=Magenta gui=NONE
highlight Character guifg=Red gui=NONE
highlight Special guifg=Blue gui=NONE
highlight Identifier guifg=DarkCyan gui=NONE
highlight Statement guifg=DarkGreen gui=NONE
highlight PreProc guifg=Purple gui=NONE
highlight Type guifg=DarkGreen gui=NONE
"highlight Normal guibg=#E0F2FF gui=NONE
highlight Number guifg=Blue gui=NONE
"highlight Cursor guifg=NONE guibg=Green
"highlight Cursor guifg=bg guibg=fg
highlight Delimiter guifg=blue gui=NONE
"highlight NonText guibg=lightgray gui=NONE
"highlight Error guifg=White guibg=Red gui=NONE
highlight Error guifg=NONE guibg=NONE gui=NONE
highlight Todo guifg=Blue guibg=Yellow gui=NONE
"#### end color settings #############

That should take care of it. Enjoy!