Matt Kirman

I Use This: Terminal Edition

I spend a lot of time working on the command line. Day in; day out. Hours at a time. This is a brief rundown of the setup that I’ve been using for some time and am finally happy with.

One quick note: In some cases I’ve extensively customised my tools from their defaults. Some of the changes are too many to detail here - I’ll go into more detail in additional posts.

My setup comprises of an extended Bourne shell, a terminal multiplexer and an advanced text editor.


Zsh

Zsh (the Z shell) is an interactive login shell with powerful command completion, extended file globbing, path expansion, spelling correction and a lot more. If you want it Zsh (probably) has it.

Zsh is installed on OS X by default but it’s quite out of date (version 4.3.11 on OS X 10.8.2). You will want to get the latest version via Homebrew instead:

$ brew install zsh
$ chsh -s /usr/local/bin/zsh $USER

In comparison to some shells my prompt is relatively straightforward. It’s tailored for a Git and Ruby development environment:

The left prompt displays information such as the username, working directory and the current Git branch. The lightning bolt indicates that there are some unstaged changes that need to be committed. My right prompt simply shows the current Ruby version (with switching enabled by rbenv).

What isn’t shown in the screenshot above is a sudo indicator. When working as a superuser the left prompt is suffixed by two red exclamation marks.

The full Zsh prompt configuration is available in my dotfiles repository.


Tmux

Rather than opening multiple terminal windows or tabs I much prefer to use tmux - a terminal multiplexer. Basically this means that you can manage multiple terminal sessions within one terminal window.

Again, tmux is available from Homebrew:

$ brew install tmux
$ tmux

I typically split my main tmux window into three sections:

  1. Vim - for writing code
  2. a command prompt - for running Rake, Git etc.
  3. a utility pane for long running processes such as Foreman and Guard that tail their logs to the terminal. This pane often gets subdivided further.

Occasionally I’ll like to push a window to a separate device such as an iPad or iPhone for monitoring long running processes away from my desk. Unfortunately tmux forces all clients to have the same window visible.

To counter this I’ve added a tmx shell script that allows clients view different windows from within the same session. Finally make sure you add the following to your tmux config so that only visible windows are resized:

setw -g aggressive-resize on

I’ve made a number of other changes to the tmux defaults - you can view my full config in my dotfiles repository.


Vim

Switching to Vim was the best thing to happen to my development workflow and day-to-day productivity despite the daunting (and seemingly never ending) learning curve.

If you’re tempted to give Vim a go I highly recommend that you stick with it for at least a couple before deciding whether it’s for you.

As usual the copy of Vim bundled with OS X is quite out of date. Install the latest version with Homebrew:

$ brew install vim
$ vim

Plugins are kept to a minimum. Due to the intricate Vim command scheme it makes sense to fully understand the editor before confusing matters with third party functionality. Bonus: my Vim isn’t that different from default making much it easier to move between unfamiliar environments.

The few plugins to make the cut include:

Usually I opt for command line Vim rather than MacVim. Differences between the two versions are minimal plus CLI Vim is accesible remotely through my tmux sessions. I haven’t found a convenient way to open files in CLI Vim from Finder or other apps quite yet; so have MacVim as the default editor for certain file types.

As before, my .vimrc and .gvimrc is available on GitHub.

Comments