Mind Blowing Command Line Time Savers
Whether you’re an old skool unix hacker or a Mac user who uses Terminal regularly, there’s lots of ways to save time on the command line. I’ve mentioned a few of the following tips on twitter.com/quiteuseful, but I thought it’d be handy to collect them all here.
Bash
!! - repeats the last command
history n - shows the last n things you’ve typed
My favourite shortcut is ctrl-r: this lets you search through history interactively. I probably use ctrl-r every day, I really don’t like repeating myself!
xargs is a useful command: it’ll construct argument lists. It works really well with pipes:
find *.rb | xargs grep -i "ActiveRecord"
Aliases
My aliases end up getting ridiculously short. I don’t ssh into my screen session with IRC, etc, I just type “irc”. I don’t even type ls either:
alias l='ls -Gla'
If you’re on a Mac you should have a ~/.profile file, so you can add aliases there.
Apps: ack and cdargs
My two favourite command line time savers are ack and cdargs. I found myself searching code a lot, and ack works better than grep for this. It’s also useful for finding documentation: why view the Rails HTML docs when you can ack the Rails source? Give it a go with one of your regularly used libraries!
You can get ack from betterthangrep.com.
cdargs lets you bookmark directories, then cd to them with a shorter name. I have a lot of code in ~/Documents/Code/project_name, and I move between projects every day. I bookmarked these with ca, then I cd to them with cv project-short-name.
You can get cdargs here: cdargs.
These apps don’t sound like a big deal, but they really help me switch between projects. Ack is great for navigating code too: you can get plugins for TextMate or Vim.

