Saturday, March 19, 2011

Customize the Titles of iTerm Windows or Tabs

Add the following line in your .bash_profile:

export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}\007"'

You could also remove the stupid "Default" by modifying net.sourceforge.iTerm.plist. Simply set Root/Bookmarks/Entries/0/Data/Name as empty.

256-color Terminal Vim in Mac OSX

The default terminal in Mac OSX does not support 256 colors, therefore I use iTerm in order to enable some pretty Vim themes.

Setup iTerm
  1. Download iTerm from
  2. iTerm's configuration interface is not very friendly. The traditional "Cmd + ," only gives you limited control. "Cmd + I" shows you some limited settings of the current session and allows you to "push" these settings to the default settings. "Option + Cmd + B" shows you all profiles, and allows you to change them. Although they appear powerful, I am unable to perform some very common tasks such as changing my default display profile to the preset "Dark background" instead of "Light background".
  3. Fortunately, iTerm puts all its configurations in ~/Library/Prefernces/net.sourceforge.iTerm.plist. Therefore, we can use any plist editor to change it in a low-level way. For example, in order to change the default display profile to the preset "Dark background", change Root/Bokmarks/Entries/0/Data/Display Profile to be "Dark Background".
  4. To make iTerm to work with 256 colors, change the terminal type in the default terminal profile to be "xterm-256color". Note: I haven't tried other types, but this one just works.
Setup Vim themes:
  1. Please refer to Color Sampler Pack. Basically, it installs Vim scripts in the .vim directory, each of which represents a Vim theme. You could also change these scripts to make it suitable for your own use.