Some nifty customizations for my CLI environment.
I decided to change the look’n feel of my Terminal. I’m using iTerm2, instead of Terminal.app, and I was usually just printing the simplest shell prompt ever:
$. I wanted to change this for a modern UTF-8 prompt, and after looking at this post on Unix & Linux, I realized that awesome shell prompts do indeed exist. Other interesting discussions can be found by following these links:
My terminal now looks like this:
Basically, current history line number, command line number, hostname, number of jobs and current directory are displayed on the first line, a left to right arrow replacing the standard Bash
$ on the second line. When in a
git repository, actual branch is printed next to the path. When last command returns an error, a red star is printed after command history. I found that displaying the number of jobs is really useful in case you want to run different programs into the same terminal, say R, python and Emacs, switch easily between them (
fg followed by jobs number to get the process back) and never forget there are running jobs when leaving it. All that is done with the pretty ugly instructions (in my
PS1="\[\e[33m\][\!:\#]\`if [[ \$? != "0" ]]; then echo $'\[\033[31m\] \ \xe2\x98\x85\[\e[0m\]'; fi\` \[\e[32m\]\h (\j)\[\e[0m\] \ \[\e[33m\]\w\[\e[0m\] \[\e[32m\]\$(__git_ps1)\[\e[0m\]\n\[\e[33m\]\$(echo \ $'\xe2\x86\x92')\[\e[0m\] " PS2=$'\\[\e[33m\\]\xe2\x86\x92\\[\e[0m\\] '
There are many shells on OS X, see e.g.
$ ls /usr/bin/*sh
Older Mac systems were using
tcsh as the default shell program. Bash was introduced when switching from OS X Jaguar to Panther, and it is now the default shell program. Of course, they are never updated and you are left with the version that ships with OS X when you buy your computer. However, we can compile newer version ourselves, unless we rely on some kind of external package manager like port or brew. I start to feel myself like a brontosaurus since I am always compiling everything by hand, but everything seems quite in order, so I don’t feel too much off base.
At the time of this writing, current version of
zsh is 4.3.17, while I have
$ zsh --version zsh 4.3.11 (i386-apple-darwin11.0)
Of course, there are lot of tutorials on internet, and as much tips and tricks we may want to try. First thing to do is, however, to customize the configuration file,
After 8 years or so of Bash, maybe its’s time to make the switch and try
zsh for, say, one week or two.
I have yet to familiarize myself with using tmux on a more regular basis. Previously, I used to use GNU screen. Installation on OS X and integration with iTerm2 went very simple: I just downloaded the tarball, compiled and installed as described in the installation notes.
I found some good tutorials here:
I added this to my
> options(colorout.emacs = TRUE) > library(colorout) > setOutputColors(4, 4, 4, 4, 3, 1, 1, FALSE)
I choose to use very few different colors, essentially for normal output (blue), warnings (orange), and errors (red).