Make My Terminal Beautiful, Part 1October 9th 2011
I spend most of my time working staring at a terminal. In fact, I'm writing this post in vim on the terminal right now. Terminal tools with color have been the norm for quite some time. Even the default installs of the major Linux distros ( Ubuntu ) enable color and alias all the right commands for you.
How do you configure these manually? Well, most of the time it's pretty simple. Here are some of the settings I use every day to make my terminal beautiful:
Lets set some of the basics. In your
~/.bashrc, try some of the following:
export CLICOLOR=1 # This will enable colors in ls by default export LSCOLORS="color_code_string" # Customize your ls colorscheme export GREP_COLOR=auto # Apply grep color automatically
Great, now ( once you either
source ~/.bashrc to refresh your settings in your
current terminal or by opening a new one ) you should have some nice colors for
some of the most basic utilities.
Next, lets look at some of our tools. To configure colors in git try:
git config --global --add color.ui true
For Mercurial, follow the directions for the ColorExtension.
Brilliant. Though... if you start an editor like vim, you will be greeted by some fairly ugly default color scheme ( but more on that in part 2 ).
I Want More
Lets check to see what type of terminal you are using.
On my machines I will see:
or maybe even:
This means the terminal emulator I'm using is presenting itself as a 256 color compatible xterm. If you do not see any of these, check the preferences for your favorite terminal application. A note for Mac users: Terminal.app on Lion supports 256 color mode, but older version do not. Try iTerm2 as an alternate terminal emulator.
We can check to see how many colors are supported for the listed terminal type in our local terminfo:
On my machines, I see something along the lines of:
Which sounds about right. If there is any other number there then either:
- Your terminal is mis-configured, or the
$TERMenvironment variable is being set in your shell without actual terminal support.
- Your terminfo database is mis-configured or just incomplete. This can be rectified by installing a modern version of ncurses.
Taste The Rainbow
Now lets try a visual test. Try running 256colors2.pl ( shamelessly lifted from www.frexx.de ). In a properly configured 256 color terminal, it should look like:
Means you have problems. Refer to the notes above, or ask me a question in the comments.
That's all for now, more in Part 2.
April 10 2012
Changed Terminal.app info, in Lion it supports 256 colors.
By Colin Kennedy