Nathan Grigg

Terminal Productivity

When it comes to working at the command line, there is really no limit to the amount of customization you can do. Sometimes it is hard to know where to start.

These are the three most helpful tools I use.

Autojump

Seth Brown introduced me to Autojump, and I am extremely grateful. It tracks which directories you use and lets you jump from one to another. All you have to do is type j and part of the directory name. So j arx will take me to ~/code/BibDesk/arxiv2bib, and then j nb will take me to ~/Sites/nb. It feels like magic.

If you have homebrew, it can be installed with brew install autojump.

View man pages in BBEdit

I use this function all the time. Man pages aren’t very useful if they are clogging up the terminal. You can easily adapt this for your text editor.

bash:
function bbm() {
cmd=$(tr [a-z] [A-Z] <<< "$1")
man $1 | col -b | /usr/local/bin/bbedit --view-top --clean -t "$cmd MANUAL"
}

The second line converts the name of the man page to upper case. This is used in the third line to set a title. The --clean option makes it so BBEdit doesn’t ask you if you want to save when you close the window.

Put the function definition into ~/.bash_profile.

IPython

I tried IPython several times before it stuck, but I can’t imagine going back to the standard Python interactive interpreter.

IPython has many, many features, but it is worth it just for the tab completion. Type the name of a variable, add a dot, and press tab to see all of the object’s methods and other attributes. Also, each history item contains the entire command, as opposed to just one line, making it possible to edit that for loop that you messed up.

The thing that kept me out of IPython for so long was that I didn’t like its default settings and didn’t want to figure out how to fix it.

In case this is stopping anyone from having a much better Python experience, here is a condensed version of my ipython_config.py file for my default profile.

python:
c = get_config()
c.TerminalIPythonApp.display_banner = False     # Skip startup message
c.TerminalInteractiveShell.confirm_exit = False # Ctrl-D means quit!
c.TerminalInteractiveShell.autoindent = False   # I can indent my own lines
c.PromptManager.in_template = '>>> '  # The IPython prompt is
c.PromptManager.in2_template = '... ' # useful, but I prefer
c.PromptManager.out_template = ''     # the standard
c.PromptManager.justify = False       # prompt.

For more information about where this should go, run ipython profile list.

IPython can be installed with easy_install ipython.