ghostty-agent-restore: after a reboot or Ghostty restart, every Ghostty tab automatically resumes the Claude Code, Codex or omp session it was running (macOS, zsh) A developer released ghostty-agent-restore, a zsh script for macOS that snapshots every Ghostty terminal pane's working directory and running agent session, then automatically resumes Claude Code, Codex or omp sessions by session ID after a reboot, crash, quit or update. The tool uses a launchd timer to snapshot panes every two minutes and a .zshrc hook to reattach each new pane to its saved entry, falling back to typing non-agent commands onto the prompt for manual execution. | | /bin/zsh | | | ghostty-agent-restore: remember what every Ghostty pane was doing, and put it back. | | | | | | snapshot record every pane: tty, terminal id, tab position, cwd, how to resume it launchd: every 2 min | | | list show the last snapshot | | | restart snapshot, quit Ghostty and relaunch it; every pane resumes its session | | | arm restore the last snapshot again: panes whose shell starts in the next 15 min take their entry | | | claim run by the .zshrc hook learn this pane's terminal id; print what to run in it | | | hook print the zsh code the .zshrc line evals | | | install launchd timer + .zshrc hook | | | | | | Restore starts by itself whenever the running Ghostty is not the one the last snapshot was | | | taken under: after a reboot, a quit, a crash or an update. When Ghostty restores its | | | windows window-save-state = always , each terminal keeps its id and gets back the session | | | saved under it. When it doesn't, each new tab you open takes the next session, in the | | | original tab order. omp, Claude Code and Codex sessions are resumed by session id and run; | | | any other command is typed onto the prompt for you to run. | | | | | | set -u | | | emulate -L zsh | | | setopt extended glob | | | | | | DIR="${GHOSTTY AGENT RESTORE DIR:-$HOME/.config/ghostty/agent-restore}" | | | CURRENT="$DIR/current.tsv" tty, terminal id, position, cwd, mode run \| type \| empty for a shell , command | | | RESTORE="$DIR/restore.tsv" entries still waiting for their pane | | | INSTANCE="$DIR/instance" "