Can I restore sessions with their scrollbacks in after closing windows and quitting iTerm?

35 views
Skip to first unread message

Borek Bernard

unread,
Nov 12, 2025, 11:19:14 AM (8 days ago) Nov 12
to iterm2-discuss
This happened to me for the first time in about five years that I'm a happy user of iTerm but instead of quitting iTerm with Cmd-Q, I accidentally clicked the red close button and then in some sort of panic state I also quit iTerm completely via Cmd-Q.

After starting iTerm again, the old sessions are all gone and Edit > Undo Close (which would probably help after just hitting the red close button and not quitting iTerm entirely) is grayed out.

Is there any way to restore the previous about 10 sessions and their scrollbacks that I had before the unfortunate series of events described above?

Thanks.

George Nachman

unread,
Nov 12, 2025, 8:17:37 PM (8 days ago) Nov 12
to iterm2-...@googlegroups.com
Undo Close is only good for 10 seconds and does not survive a restart of the app. The restorable state exists in ~/Library/Application Support/iTerm2/SavedState. If you have a backup (like Time Machine) then you can:

  1. Quit iTerm2
  2. Restore that directory from backup (making sure to replace everything there - the .sqlite-wal file might be present in the most recent version but not in a backup, for example)
  3. Relaunch the app

That should restore your windows as they were at the time of the backup. Let me know if that gives you trouble, since you’ll probably hit some rarely used code paths in so doing.

--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/iterm2-discuss/ce595f67-3d9d-4138-85b1-18e002ac00b4n%40googlegroups.com.

Borek Bernard

unread,
Nov 13, 2025, 2:09:13 PM (7 days ago) Nov 13
to iterm2-...@googlegroups.com
Thanks for the reply, I don't have a backup so can't really try that but appreciate your response anyway.

I don't know how much disk space it would cost but maybe storing recent sessions for a few weeks could be useful to have? It would add peace of mind.

čt 13. 11. 2025 v 2:17 odesílatel George Nachman <gnac...@llamas.org> napsal:
You received this message because you are subscribed to a topic in the Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/iterm2-discuss/lKe89iMr3rY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to iterm2-discus...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/iterm2-discuss/CAB5Rqo%3DucPRu6O5GrPENDt0CTycvY5GqvZuHHeJ7ejiuGbJviQ%40mail.gmail.com.

George Nachman

unread,
Nov 14, 2025, 12:45:55 AM (6 days ago) Nov 14
to iterm2-...@googlegroups.com
It’s not something that could be turned on by default because it would use a ton of disk space and create privacy issues, unfortunately. My inclination is that a backup is a much simpler solution, although it’s certainly hard to discover. Another option that might make more sense is automatic session logging, which is already there. It wouldn’t let you restore the session back into a window, but at least your data would be preserved in an easily accessible way indefinitely.

Julian Elscher

unread,
Nov 14, 2025, 2:18:04 AM (6 days ago) Nov 14
to iterm2-discuss
I have session logging turned on. by default and clear it out "now and then".  it's usually a waste of space, except when it isn't and saved your life. 
It might be nice if you could limit to some timescale or size automatically but that could take a lot of work to do right.

I usually run through tmux integration so there is tmux's scrollback as well. 

What would be really cool would be if on attaching, iTerm would allow the user to scroll back through tmux history.
Reading back through an old session log might be useful.  mayne just adding a dialog box to allow the slelction of the file and a simple a window to read in the log as though it was scrollback..

whether that means importing the data from tmux or reading it a line at a time as the user scrolls up.

I don't believe that works now though I have been surprised a few times about things in scroll back.

Reply all
Reply to author
Forward
0 new messages