I forked Ghostty so my terminal remembers my tabs
I've published a fork of Ghostty: henricook/ghostty. It does one thing upstream doesn't: on Linux, when you close Ghostty and reopen it, you get your session back. Tabs, tab names, split layouts, working directories, which pane was focused. Optionally even scrollback.
Fair warning up front: this is going to be barely maintained at best. It's pinned to whenever I last felt like rebasing from upstream, it's tested on exactly one machine (Wayland, GNOME, Ubuntu 26.04, mine), and if it breaks for you I'll be sympathetic but probably not very useful. I built it for myself; it's public because there's no reason for it not to be.
Ghostty is great, this is the one gap
I really like Ghostty. It's fast, it's native, the config system is sane, and terminal emulation quality is clearly treated as a craft rather than an afterthought. But coming from years of muscle memory where my terminal just... comes back the way I left it, the Linux build has a gap: window-save-state is macOS-only. Quit Ghostty on Linux and you're starting from scratch.
To be clear, the Ghostty team know this and have much better ideas about it than I do. There's a proper feature request with real deliberation in discussion #12055 (the official position is roughly "the right place for this is GTK's session management, let's not hack around it"), a long-standing issue about including scrollback in state restoration (#1847), and a good thread about making save/restore automatic for new users (discussion #12912). When upstream ships their version it will be better than mine and I'll happily delete this fork.
But those are all "eventually". I wanted it now. So this is the "now" version, built on the shoulders of PR #12962 by fhackenberger, a perfectly decent stop-gap implementation that got auto-closed by the contribution process rather than on merit. I took that as a base, adapted it to current main, and extended it with the bits I actually cared most about: full split-tree layout restore, focus restore, and restore-time backups of the session file. Claude did most of the grunt work; I did the wanting and the arguing about design.
What it remembers
- Windows: size and maximised state. Not position, Wayland doesn't let apps place themselves.
- Tabs, in order, including which one was selected.
- Tab names, but only ones you set yourself. Titles set by the shell aren't persisted, your fresh shell will just set them again.
- Split layouts per tab: every divider's orientation and ratio, plus zoom state.
- Working directory per pane (needs shell integration, which is on by default).
- The focused pane.
- Scrollback, optionally, if you set
window-save-state-scrollback-size. Off by default.
Shells are started fresh. It does not restore running processes, it's a terminal not a time machine.
State lives in ~/.local/state/ghostty/<app id>/session.json as plain, readable JSON, written atomically. Every successful restore also snapshots the file into a backup/ directory next to it (last 10 kept), so a good layout can't be permanently clobbered by accidentally closing a throwaway window.
Building it (Ubuntu-ish instructions)
You need Zig 0.16.0, which your distro probably doesn't package:
curl -LO https://ziglang.org/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz tar -xf zig-x86_64-linux-0.16.0.tar.xz -C ~/.local/opt ln -s ~/.local/opt/zig-x86_64-linux-0.16.0/zig ~/.local/bin/zig
Then the GTK build dependencies and the build itself:
sudo apt install -y libgtk-4-dev libadwaita-1-dev blueprint-compiler \ gettext libxml2-utils libgtk4-layer-shell-dev git clone https://github.com/henricook/ghostty.git cd ghostty zig build -Doptimize=ReleaseFast
The binary is zig-out/bin/ghostty and it finds its resources relative to itself, so you can run it in place. To make it your actual terminal, install the generated launcher, icons, and the D-Bus service file (the launcher declares itself D-Bus activatable, and without the service file GNOME clicks fail silently, which cost me a confused half hour):
cp zig-out/share/applications/com.mitchellh.ghostty.desktop ~/.local/share/applications/ cp -r zig-out/share/icons/* ~/.local/share/icons/ mkdir -p ~/.local/share/dbus-1/services grep -v '^SystemdService=' zig-out/share/dbus-1/services/com.mitchellh.ghostty.service \ > ~/.local/share/dbus-1/services/com.mitchellh.ghostty.service
(The grep -v strips a systemd unit reference that doesn't exist for user-level installs.)
One gotcha worth knowing: session save/restore only runs for the canonical single instance. Launching from your desktop environment is fine, but if you launch it from inside another terminal for a quick test, Ghostty detects that and turns single-instance off, and the feature silently does nothing. Add --gtk-single-instance=true when testing from a terminal.
To turn the whole thing off: window-save-state = never.
More detail, including maintenance notes and the design decisions, is in FORK.md in the repo.