
As a developer, whenever you have the need to restart your machine, everyone would want to resume from where we left. Most apps like web browsers, code editor support restoring all tabs or windows after a restart but terminal in the past have not been great. Even if terminals have added support at a later point, developer have got used to the fact we have to start from scratch. So whether restore works or not, I really didnโt care for many yeats. But recently, I have enjoyed the restore tabs/windows feature even in terminal.
When I set up iTerm2 on a new machine, it didnโt work. So I was looking into iTerm2 settings but it wasnโt working. Thatโs when I realized macOS and iTerm2 offer different ways to restore your previous session.
Reopen iTerm2 Windows Using macOS settings
MacOS has the settings โClose windows when quitting an applicationโ in System Settings -> Desktop & Dock -> Windows -> โClose windows when quitting an applicationโ. By default this is disabled. Since iTermโs default window restoration policy was set to โuse system settingsโ, windows wasnโt getting restored after quitting the app.
This system settings is macOSโs built-in restore feature, which will ensure it reopens all your previous iTerm2 windows. Once you enable โClose windows when quitting an applicationโ in system settings, windows in iTerm will be restored, as is, in the same state, before quitting the app.


On top of this there are other settings in iTerm2. One among that is under General -> Window -> โRemember the size and position of previously closed windowsโ. This is optional since macOS takes care of this.

iTerm2 also provides automatic restoration every time, enable Preferences โ General โ Startup โ Open default Window Arrangement. You can also save custom window arrangements and restore them later. For some reason, this option is disabled. Hence I have rely on macOS system settings.
Other iTerm setup
If you are new to iTerm you can checkout other setup guides that I have written, these setup would make you developing more interesting and fun.
