There is no Cmd+Shift+T to reopen a closed window in Apple's Terminal.app — that shortcut works in browsers, not in Terminal. But "I closed the window" rarely means "I lost the work." The window is just a view onto a shell, and the two things you actually care about — the commands you ran and the program that was running — are usually recoverable from elsewhere. This guide covers Terminal.app, iTerm2, recovering your command history, and resuming long-lived CLI tools.
Closed a window that had Claude Code running in it? Your conversation is safe on disk regardless of the terminal. See How to recover an accidentally closed Claude Code session, then come back here to reopen the window itself.
Quick Reference
| Goal | How |
|---|---|
| Reopen windows after quitting Terminal | System Settings → Desktop & Dock → uncheck Close windows when quitting an application, then Cmd+Q and relaunch |
| Recover commands you typed | New window → Up arrow or Ctrl+R (reverse search); file is ~/.zsh_history |
| Reopen the last closed iTerm2 window | iTerm2 restores sessions on relaunch (see iTerm2 settings below) |
| Keep a session alive across closes | Run it inside tmux or screen, reattach with tmux attach |
| Resume a long-running tool's state | Use that tool's own resume feature (e.g. Claude Code's claude --continue) |
Terminal.app: What You Can and Can't Get Back
You can't reopen a single closed window directly
If you press Cmd+W (close window) or Cmd+Q (quit) and the window is gone, Terminal.app offers no menu item or shortcut to bring that exact window back on demand. There's no "Recently Closed" list like Safari's.
You can make windows return on relaunch
macOS has a system-wide window restoration feature. When it's enabled, quitting and reopening an app restores the windows it had open:
- Open System Settings → Desktop & Dock.
- Scroll to Windows and turn off "Close windows when quitting an application."
- Now
Cmd+Qto quit Terminal, then reopen it — your previous windows and tabs reappear.
The catch: this triggers on quitting and relaunching the whole app, not on closing one window while Terminal stays open. If you closed a single window and other Terminal windows are still open, restoration won't bring the closed one back.
Recover the commands you typed
This is usually what people actually want. Your shell records every command to a history file:
- zsh (the macOS default since Catalina):
~/.zsh_history - bash:
~/.bash_history
In a fresh window:
# Step back through recent commands
# (press the Up arrow repeatedly)
# Search history interactively
# press Ctrl+R, then type part of the command
# Print the whole history
history
# Find a specific command
history | grep ssh
Important caveat for zsh: by default zsh writes history to the file when the shell exits cleanly. If the window was force-closed or the Mac crashed, the last few commands from that session may not have been flushed. To make zsh save history immediately after every command, add this to ~/.zshrc:
setopt INC_APPEND_HISTORY # write each command as it's entered
setopt SHARE_HISTORY # share history live across open shells
iTerm2: Better Restoration
iTerm2 restores far more than Terminal.app. By default it can reopen the sessions you had running when it last quit:
- iTerm2 → Settings → General → Startup controls window-restoration behavior on launch.
- Window restoration can bring back your split panes and tabs after a relaunch.
- For deliberate recovery, save your layout with Window → Save Window Arrangement, and restore it later with Window → Restore Window Arrangement (or set it as the default arrangement so it loads on every launch).
As with Terminal, iTerm2's restoration triggers on app relaunch — it is not an undo for a single Cmd+W. The command-history recovery steps above apply identically in iTerm2.
Don't Lose It Next Time: Persistent Sessions
If you regularly run long tasks (builds, training jobs, SSH sessions, servers), put them inside a terminal multiplexer so a closed window never kills them:
# Start a named session
tmux new -s work
# ...run your long job...
# Detach by hand (session keeps running): press Ctrl+B then D
# Or just close the window — the session survives, detached
# From ANY new window, list and reattach:
tmux ls
tmux attach -t work
screen works similarly (screen -S work to start, screen -r work to reattach) and ships with macOS. With tmux/screen, closing the window only detaches you — the processes keep running and your scrollback is intact when you reattach.
Resuming Tools That Save Their Own State
Many modern CLI tools persist their state to disk and don't care that the terminal window closed. The best example is Claude Code, which writes every conversation to a transcript file under ~/.claude/projects/. Closing the window doesn't delete anything — you reopen a terminal, cd back to your project, and run:
claude --continue # resume the most recent conversation in this directory
# or
claude --resume # pick from a list of past sessions
The full walkthrough — including how the transcript files are organized and how to recover a session from any window — is in How to recover an accidentally closed Claude Code session.
Summary
- macOS Terminal has no "reopen closed tab" shortcut — Cmd+Shift+T won't help.
- Turn off "Close windows when quitting an application" to make windows return on relaunch.
- Recover typed commands from
~/.zsh_historywith the Up arrow, Ctrl+R, orhistory. - iTerm2 restores sessions and saved window arrangements on launch.
- Use tmux/screen so a closed window never kills a long-running job.
- Tools like Claude Code persist their own state — just relaunch and resume.