Arjun Sajeev

Custom Iterm2 layouts with itermocil

If you frequently work with web development projects, you tend to run a lot of scripts during development. For example, if you are working on a full stack node project you might run npm start, npm run watch and maybe npm run server. It is usually convenient to run them in different panes in a single tab in Iterm2, so that you can see everything in one place.

Iterm2 lets you save and restore layouts from Preferences but itermocil lets you write YAML files for custom layout arrangements and relaunch them quickly.

Here is a sample YAML for a simple 2-pane layout.

windows:
- name: website
root: ~/Dev/website
layout: even-horizontal
panes:
- npm run dev
- npm run server

You need to save your custom layouts in ~/.itermocil and then you can launch the layout using the following command.

itermocil <layout-name>
#<layout-name> is the filename of the layout file in ~/.itermocil

I aliased itermocil to t so that I can launch any of my custom layouts with t <layout-name>. Now I can start working on my website by just using t www. A nice side effect is that I no longer have to remember what scripts to run per project, I can start hacking on any project with a single command.