I spend so much time in front of my glowing terminal that I probably have terminal tan. The purpose of this post is to talk about the tools I use and share some nifty commands I have learned over the years.

The terminal program itself: iTerm2

OS X's default terminal is Terminal but I switched to iTerm2. With Terminal I used to use the tmux terminal multiplexer but the panes in iTerm2 seem a bit more friendly. For a list of iTerm2 features see http://www.iterm2.com/#/section/features. One of my favourite features is


which broadcasts keyboard input to all panes at once. When I'm wearing my SysAdmin hat I often want 4 ssh sessions each in its own pane: editor, logs, logs and more logs. Broadcasting input makes this easy.

Shell: Z shell (zsh)

Bash is the more standard choice. I use zsh because of its auto-corrections and because of the popular GitHub repo oh-my-zsh: https://github.com/robbyrussell/oh-my-zsh which is a framework for managing zsh plugins. There are some really nice oh-my-zsh themes. My favourite is agnoster:

zsh - agnoster

Shell tricks:


is the most useful thing ever. If you half remember a command or can't be bothered to write a long command again then ctrl+r will search through your commands and when your previous command is found, just hit enter and the command will re-execute. I often want to change the command slightly so I often press an arrow key and edit the command before I hit enter. This beats my old method: history | grep some-command, getting the command number (say 182) and pasting the command (!182) (although this is sometimes useful too).

cp /etc/my-important-config-file-that-has-a-really-long-name{,bak}

instead of

cp /etc/my-important-config-file-that-has-a-really-long-name /etc/my-important-config-file-that-has-a-really-long-name.bak

This is called brace expansion and it is second most useful thing ever. When I'm setting up some Linux service I always backup the config file in case I break something and don't remember what I changed. When you have a long path, it can be a pain writing the same directory out twice - this makes the process nearly twice as fast.

grep ---recursive --line-number foo .

The above recursively searches the current directory ('.') for the string 'foo' and shows the line number. Note that I actually use the shorthand grep -rn foo . in practice.

Editor: vim

I'm not going to start another editor war but I will post this link: http://www.rudism.com/s/vimcreep.

Version control: git and tig

I use git for everything now. I version control my documents as well as my source code. I use Bitbucket for my private repos (because it's free) and GitHub for open source stuff. One powerful git command is git add -p . This command interactively goes through the changes in your file and asks you whether you want to stage each part of the file or not.

tig is a nice text-mode interface for git:


Multiple dev machines

I work on a couple of different machines but I often tweak my .vimrc on one machine but then want it on another too. I have a vim-settings repo on GitHub with a simple deploy script to configure vim for a new machine: https://github.com/cjwfuller/vim-settings

How can you improve your workflow?

I'm a programmer and if I'm optimising code then I run the program through a profiler to find the place where the program is spending the most time (often in about 20% of all the code!) and then I optimise the 20%.

You can (sort of) profile your workflow. What are you top 10 most used programs? Find out by running something like:

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10 

and work on improving your use of the most commonly used tools.

(command taken from http://superuser.com/questions/250227/how-do-i-see-what-my-most-used-linux-command-are). Think of laborious things you have to do in your terminal and optimise.