Making iTerm2 Usable for Development

0 Flares 0 Flares ×

Developers Dilemma

Every developer has spent probably more hours than they want trying to get a terminal or console to work for their development style. I know I have spent way to many hours on this task and I finally found a system that’s working for me.

The problem for me has always been how do quickly get into a development environment and start working when I get on my computer. Then how do I just as quickly tear that environment down knowing I can pull it up quickly the next time I need it.

Tools like Vagrant and other offer great ways to get the operational side of this development environment up but unless you want to work in a heavy IDE like Eclipse I’ve always struggled with the authoring side of this problem.

That is until I started working with iTerm2 and SublimeText 3. Between these two tools I can quickly create new pieces of software and start whole new projects.

I know many of you are probably using SublimeText already so know what I’m talking about when it comes to getting up and running on a new project there. I’ve been asked by a few people though how do I just as quickly setup a savable environment in iTerm2.

iTerm2 breaks this into two parts Window Arrangements and Profiles so let’s get into setting these up for repeatable environments.

Profiles, Profiles, Profiles

Yep you’ve got to create a few profiles.

Open up the profiles menu from the iTerm2 preferences (cmd-,) go to the Profiles tab.

Most Wanted

I start with creating a Previous Directory profile. This is my goto profile for most windows as it will automatically go back to the last place it was when your restore a session that has this profile.

Name it how you want.

The only setting you need to have is the radio for Reuse previous session’s directory under the Working Directory subsection.


Development Bliss

I also setup profiles for each of my runnable tasks such as MongoDB.

For these you’ve got two things to set. First set the working directory by selecting the Directory radio from the Working Directory option and setting it to the directory you need run your command from

Now you need to add your command and any options to the Send text at start from the Command subsection.

Window Arrangements…

Window arrangements are the glue to a an easy environment in iTerm2.

To setup a window arrangement you must start from a blank slate, by this I mean close all open iTerm2 terminals (cmd-w).

Now we open the windows and start generating a dev environment. I’m going to walk through creating an environment for my current startup.

We’ll need runners for MongoDB, Redis, my application frontend server and my application backend server. We’ll also need a window for checking code in.

Create a new window (Shell -> New Window or cmd-n).


This is our canvas and now we’re going to draw the rest of the environment using the options to split pane.

First I split the pane vertically by right clicking and selecting split pane vertically.

I continue splitting vertically and horizontally until I have all the panes I need in an arrangements I like.

Note: you can drag the edge of any pane to resize it.

Next we’ll map these sessions to desired profile. Click on the little gear for each pane and select Edit Session.


Pick the right profile and then click Change Profile. Name the pane (this will show in the upper left of the pane).

Close this panel (the red button or cmd-w). Repeat for each pane.

Note: For the code pane I use the Previous Directory profile then move to the code directory before the next step.

Now we need to save this marvelous new environment by saving the window arrangement (cmd-shift-S or Window -> Save Window Arrangement). Enter a name and your done.

Let’s test that it works.
1. Close your arrangement
2. Window -> Restore Window Arrangement -> Your Arrangement



Your Tips

If you have further tips I’d love to hear about them in the comments section below.

  • Michael Pelikan

    Is there a way for each window arrangement to maintain the name in the title bar? Once you get two or more window arrangements, it can become confusing to get context.

  • Jennifer

    I am soo pleased to have this set up! Thank you sir! It will be nice when you can name each pane.

  • Jennifer

    Has anyone ever tried to remove a saved window arrangement?

    • Paul Ryan

      To remove a saved window arrangement go to preferences (cmd-,) -> Arrangements. Select the arrangement you want to delete then click the little minus button in the lower left corner.

  • When I open my windows arrangment. tabs doesn’t open in the directory which I have setuped in profile setting

    • Paul Ryan

      @jitendravyas:disqus you need to make sure that the profile is saved as part of the window. Use the little gear icon on the window you want to change and Edit Session.

      From there you can update the profile. Make sure you also re save your window arrangement or you’ll lose this setting on the next open.

      Hope this helps.

      • mato

        How exactly, please? I’m using the latest iTerm2 (v.3) and there’s no such option in Edit Session. Working directory is only settable in general Preferences. And it does not seem to work for me either.
        I consider this part of iTerm2 not really friendly. Ideally I should be able to save window arrangement with working directories.

        • mato

          OK, it turned out to be an issue caused by garbage in iTerm’s config file. You know I’ve been using iTerm for years. So I removed plist and started afresh and it all works now.
          PS: I think iTerm2 should warn users about old config files. That could avoid many issues (and dev/user efforts to resolve them).

          • Paul Ryan

            Sorry I missed this, glad you got it worked out.