Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I save tabs on exit in my iTerm 2, so I don't have to open same directories again after restart?

Like Chrome does, for example.

I couldn't find such option in settings. Maybe "Arrangements" is what I want, but it seems that it requires me to explicitly save tabs.

share|improve this question
iTerm 2 will open your saved Window Arrangements if you need that and don't like iTerm or on Lion. It works on Snow Leopard as well. – bmike Aug 18 '11 at 19:40
ouch, I had no idea that iTerm 2 is something different from iTerm. I used iTerm 2. Can it save Window Arrangement on exit? I couldn't find out how – valya Aug 18 '11 at 20:03
You have to explicitly save the settings from my brief read of the FAQ - we'll see if anyone here knows for sure now that the question is razor sharp :-) Nice edits. – bmike Aug 18 '11 at 20:05
iTerm2 has no support for reopening directories. This ticket can be used to track the implementation: – Jörn Zaefferer Sep 16 '14 at 22:00

You can Save and Restore Window Arrangement with ⇧ ⌘ S and ⇧ ⌘ R options under the Window screen in iTerm2

You can start the default Arrangement Option to enable are at Preferences -> General -> Startup -> Open default window arrangement .

You can add arrangements with the ⇧ ⌘ S and manage them under Preferences -> Arrangements tab .

iTerm Window Options

share|improve this answer
the one detail that was important for me here: first arrange windows like you want to have them, then hit ⇧⌘s and save as 'Default' (without the quotes, capitalized). the exact spelling is also shown on the Window > Restore Window Arrangement submenu. any other spelling will save the arrangement alright but not restore it on iTerm restart. – flow Oct 20 '13 at 13:52
This does not answer the original question of "Can I save tabs on exit in my iTerm 2, so I don't have to open same directories again after restart?" – Jeremy Lee Jul 15 '14 at 17:56
@JeremyLee Indeed. One will have to couple Window Arrangement with profile arrangement, like mentioned by Rob below, to achieve this purpose. – JI Xiang Feb 1 '15 at 8:07
This doesn't do what Chrome does, it seems. Chrome re-opens the tabs that were open when you last quit it. This seems to be more like something Internet Explorer did ages ago, where you could tell what it should open every time you start it, regardless of what was open last time. – Daniel C. Sobral Jul 7 at 21:06

Here's what I do, running OSX 10.10.4:

Install iTerm nightly (the latest release). Brew is the easiest:

brew tap caskroom/versions && brew cask install iterm2-nightly

You can run this side-by-side with other versions; I use Spotlight and look at the versions to see which one I'm opening. By default it will be set to enable session restore which will restore tabs and directories. However, you may have to adjust your Apple system preferences in System Prefs>General where Close windows when quitting an app. See this Gitlab issue for a screenshot if that confuses you.

share|improve this answer
This is a new feature in at least iTerm 2.9.20150626 beta. They elsewhere confusingly refer to it as part of the iTerm2 version 3 beta. Anyway, automatic session restore rocks! – Bluu Aug 21 '15 at 18:22
As new as this answer is, it seems that there is currently no iterm2-nightly Homebrew cask. – David Resnick Aug 24 '15 at 11:43
Thanks David - I updated it to refer to – Ben Creasy Aug 24 '15 at 16:44

Coming in quite late, but you should first create some profiles and then use Command - Option/Alt - Shift H (H is for horizontal split; or swap in V for vertical split). It will show you a list of your profiles and you can then add those to your split. Once you build the setup you like just like Sairam did above.

Here's a vid explaining: iterm2 Profiles and Window Arrangements.

share|improve this answer

It's still not exactly what you want, but since you can check the $ITERM_SESSION_ID environment variable to see which panel you are in, by combining this with a saved window arrangement, you can have each of your panel to start with different initial path, or just anything you would like to run by default.

For example, my saved windows arrangment is two tabs with two panels in the first tab. So I will have $ITERM_SESSION_ID=w0t0p0 for the first panel in the first tab, $ITERM_SESSION_ID=w0t0p1 for the 2nd panel, and $ITERM_SESSION_ID=w0t1p0 for the single panel in the 2nd tab. 'w' stands for window, 't' for tab, and 'p' for panel. I check these variables in my .zshrc, and run Vim in the w0t0p0, iPython in the w0t1p0, respectively.

share|improve this answer

In iTerm2 v2.1.4 there's a setting under Profiles: Reuse previous session's directory. It may have been there in the earlier versions, but I haven't looked.

See screenshot:


share|improve this answer

If someone like me is having trouble enabling 'Session Restoration' in iTerm 2.9 beta (or iTerm3 beta how they call it) do next:

  1. Open preferences
  2. General tab
  3. Startup
  4. Change to 'Use System window restoration setting'. Restart.

enter image description here

Probably for tech geeks it's obvious that one should select this option for this feature to work but for me it was not and I have never seen this mentioned anywhere.

share|improve this answer

No, as of today I couldn't find any way to set a layout/tabs with paths and recover it (as Sublime Text does for example) in iTerm (2.9).

Personally, I'm astonished on how a basic feature (I think much more relevant than tabs colours, for example) is still missing on such a mature project.

share|improve this answer

Try iTermocil

iTermocil allows you to setup pre-configured layouts of windows and panes in iTerm2, having each open in a specified directory and execute specified commands.

share|improve this answer
Can it also preserve tabs and the working directories of the different tabs (as asked in the question)? – patrix Nov 3 '15 at 7:59
@patrix yes, it has to be set in yml file, however this does not restore tabs on iTerm restart – forloop Nov 4 '15 at 9:36
this is uh-mazing, thanks – delboud May 25 at 3:56

This is possible with iterm2:

You can toggle this feature with Prefs>Advanced>Enable session restoration, but you must restart iTerm2 after changing this setting.

I also had to uncheck "close windows when quitting an app" in my General system preferences:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.