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.

  • iTerm 2 will open your saved Window Arrangements if you need that and don't like iTerm or Terminal.app on Lion. It works on Snow Leopard as well.
    – bmike
    Aug 18, 2011 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, 2011 at 20:03
  • 1
    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, 2011 at 20:05
  • 1
    iTerm2 has no support for reopening directories. This ticket can be used to track the implementation: code.google.com/p/iterm2/issues/detail?id=2775 Sep 16, 2014 at 22:00
  • 1
    It's a nightmare, but really useful once you set it up. I documented the full process in a blog post which is too long to post on StackOverflow.
    – Andy Ray
    Jun 6, 2017 at 22:37

12 Answers 12


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

  • 4
    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, 2013 at 13:52
  • 34
    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
    Jul 15, 2014 at 17:56
  • @JeremyLee Indeed. One will have to couple Window Arrangement with profile arrangement, like mentioned by Rob below, to achieve this purpose.
    – xji
    Feb 1, 2015 at 8:07
  • 1
    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. Jul 7, 2016 at 21:06
  • 2
    @flow You can also go to the arrangements tab in preferences, select a given arrangement and click 'set default' in the lower left hand side of the screen Oct 13, 2017 at 15:18
  1. In iTerm go to Preferences -> General and under Startup set Use System Window Restoration Setting. enter image description here

  2. Go to macOS System Preferences -> General and make sure that Close windows when quitting an app is unchecked. enter image description here

  • 2
    works great on macOS Catalina (10.15) and iTerm 3.3 Feb 14, 2020 at 10:30
  • 4
    This answers the question correctly with a simple approach. Thank you.
    – Tyler
    Apr 17, 2020 at 21:38
  • 5
    This should be the accepted answer Jun 19, 2020 at 12:11
  • 1
    I feel like there's one more thing at play here. I have the same settings on 2 Macs, both running Big Sur. On my M1 Mac, the tabs are restored and each session is in the directory where I left off. On my Intel Mac, the tabs are restored and I see the tab's history, but every session is in my home directory. Not sure what the difference is.
    – chrispix
    Aug 25, 2021 at 19:00

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.

  • Can it also preserve tabs and the working directories of the different tabs (as asked in the question)?
    – nohillside
    Nov 3, 2015 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, 2015 at 9:36
  • This is exactly what I needed!
    – dhempler
    Jul 22, 2017 at 13:44
  • 2
    This project seems to be unmaintained as of 2021 :( May 2, 2021 at 14:23

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.

  • 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, 2015 at 18:22
  • As new as this answer is, it seems that there is currently no iterm2-nightly Homebrew cask. Aug 24, 2015 at 11:43
  • 1
    Thanks David - I updated it to refer to github.com/caskroom/homebrew-versions
    – Ben Creasy
    Aug 24, 2015 at 16:44

This is possible with iterm2: https://www.iterm2.com/documentation-restoration.html

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: https://support.apple.com/en-us/HT204005.


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.


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.


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.


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.


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:



Disabling the System Preferences -> General -> "Close windows when quitting an app" checkbox did the job for me.


I found the solution in iTerm2's official website, check it out here https://www.iterm2.com/documentation-restoration.html.

After setting iTerm2 restores last session just like Chrome. However the process(e.g. npm start) can not be restored.

Works perfectly under iTerm2 build 3.0.14 and macOS Sierra 10.12.6 (16G29). Hope it helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .