Configuring iTerm2

8 May 2017

If you’re going to use the command line you need a command line interface. Mac OSX comes with the Terminal application, and for most purposes this is perfectly sufficient. There’s even a fair amount of customisation (colors etc) you can perform to make it suit you better than the default configuration.

However, iTerm2 has a whole load of additional features that can make your workflow a lot smoother, and when you’re developing you spend so much time using the command line that even tiny adjustments to your workflow can add up over the course of a day or a week to a significant improvement.

You can download iTerm2 for free here: www.iterm2.com

Here are some tips for using and configuring iTerm2…

Fullscreen and system-wide show/hide

Benefit: It can be fiddly switching between a browser and a terminal, and when you’re developing you do it all the time. This method makes it effortless.

Cmd + Enter turns iTerm2 fullscreen. I leave it on fullscreen basically all the time, and switch between iTerm2 and whatever else I’m doing using a system-wide hotkey. You can set this by going into iTerm > Preferences > Keys > Hotkey. I use Alt + Space, which is super easy to jump your hand to, but you can set it to anything you want. Be careful that it isn’t a command that is used by one of your other applications though.

Transparency and blur

Benefit: When you use the previous tip and switch between fullscreen iTerm2 and everything else it can be a bit cognitively jarring with such an abrupt change. Making the iTerm2 window a little bit transparent and blurring everything else can solve that problem.

You can set the transparency of the iTerm2 window in iTerm > Preferences > Profiles > Window > Window Appearance. I have mine about 1/5 the way from opaque to transparent. Any more transparent than that and I struggle to read what’s written in iTerm2. I also have a small amount of blur just to emphasise the focus on iTerm2.

With these first two tips combined, it’s easier to think of yourself as looking at the same thing in two different ways, rather than looking at two different things. Somehow I find that easier in terms of cognitive load.

Pane arrangements

Benefit: When you’ve got iTerm2 in fullscreen mode you’ve got plenty of space to see more than one pane at a time. So when you need more than one terminal windows open you don’t have to fiddle about switching between them.

You can set up a pane arrangement by right clicking in the terminal window and selecting either “Split Pane Vertically” or “Split Pane Horizontally”. You can then split either of the resulting panes further. Once you’ve got the arrangement you like Window > Save Window Arrangement allows you to save it with a name of your choice so you can access it again later with Window > Restore Window Arrangement.

I also recommend setting your favorite arrangement as a default in iTerm > Preferences > Arrangements > Set Default. Then check iTerm > Preferences > General > Startup > Open default window arrangement and you will get your preferred arrangement every time you open up iTerm2. (You can also uncheck “Open profiles window” here if it’s annoying you. I’ve never needed more than one profile so far.)

Colors & font

Benefit: Since you’ll spend so much time looking at the terminal, its appearance is important. Two considerations for colour here:

  1. Looking at a computer screen for a long time can be hard on the eyes. Colors can help to soften the experience, e.g. picking a black background over a white one.
  2. Pick colors you actually like since you have to look at them so often!

You can change the default iTerm2 colors by going to iTerm > Preferences > Profiles > Colors and there’s a dropdown menu at the bottom. There are 5 pre-installed color schemes there to choose from, but you can find many more on the iTerm2 color schemes website. To use them, download either the tar.gz or the .zip file, extract the contents, and then import the color scheme of your choice using the import option in that dropdown menu.

I went for Twilight, which has nice muted colors. Be careful though that the colors are distinct enough. For example, sometimes when I’m testing it prints out passing results in green and failing results in red, and there are some color schemes (e.g. Spiderman) where this difference is not obvious. So the best option depends on what else you’re using that prints colored output to the terminal.

Also pick a monospace font you like in iTerm > Preferences > Profiles > Text. I’ve gone for Monaco, which ships with OSX.

Shortcut keys

Benefit: For anything you type out all the time, especially things that require repetitive keystrokes, shortcuts can save you a ton of time.

Some built-in shortcuts I also use all the time are:

  1. Cmd + ] - Cycle through panes clockwise.
  2. Quadruple click: smart selection so you can get eg a full URL rather than a part of it that happens to be a word.

You can add a keyboard shortcut in iTerm > Preferences > Keys > Global Shortcut Keys (then click on the + symbol). Type in the key or combination of keys you want to use for the shortcut and then select the action desired.

What the best shortcuts are depends partly on what you personally spend your time doing, but I guarantee these will make your life a lot easier:

  1. Cmd + Left Arrow - Send Hex codes: 0x01 (Go to beginning of line)
  2. Cmd + Right Arrow - Send Hex codes: 0x05 (Go to end of line)
  3. Cmd + Delete - Send Hex codes: 0x15 (Delete back to beginning of line)
  4. Alt + Left Arrow - Send Escape Sequence: B (Jump one word left)
  5. Alt + Right Arrow - Send Escape Sequence: F (Jump one word right)
  6. Alt + Delete - Send Hex codes: 0x1B 0x08 (Delete one word)

Conclusion

iTerm2 has a whole load of features that can improve your terminal experience, I highly recommend it. You can find out about some of the other features I haven’t mentioned here, and if you think I’ve missed something important off this list then let me know!

comments powered by Disqus