← All writing

Developer Tools

OSC 7577: Your Terminal Can Now Resume Your Programs

Mani G 3 min read

Dark terminal window with editor, coding agent and log panes, circled by a green and amber restart arrow, labeled OSC 7577

Say you have Neovim open with six splits, a coding agent mid-conversation, and a dev server in a third pane. Then your terminal updates itself and restarts. You get a clean, empty shell and a sinking feeling. OSC 7577 is a new open protocol that aims to fix exactly that: it lets a program tell your terminal how to bring it back after a restart.

Mitchell Hashimoto announced it on 25 November 2026, alongside a Rex feature that resumes programs through a server restart. He said the protocol was built with the team behind herdr, a terminal workspace tool, with review from other terminal emulator and terminal program authors. The herdr team said auto resume had been their most requested feature, and that they picked an open protocol over a herdr-only version with per-agent hooks. Good call, in my view.

What OSC 7577 actually does

OSC stands for Operating System Command. It is an old trick: a program prints a special escape sequence, and instead of showing it, the terminal treats it as a message. Sequences like this already set window titles and make clickable links. 7577 is simply the number picked for this one.

With OSC 7577, a program prints a report that says, roughly, "if you restart, run this command in this folder." The report is a short list of key=value pairs:

  • pid: the process the report is about
  • time: when the report was sent, in Unix seconds
  • argv: the resume command, each argument in base64
  • cwd: the working directory (optional)
  • mac: a SHA-256 hash that proves the sender knows a secret token

The spec's own example is Neovim. After saving a session file, Neovim could report nvim -S /home/user/.local/state/nvim/sessions/8f2c1d.vim. After a restart, the terminal runs that and your splits come back. When a program no longer wants to come back, it sends clear=1.

The security part is the interesting part

A resume command is a command your terminal will run later, as you, without you typing it. That is a scary sentence. If any text could register one, then running cat on a nasty file or SSH-ing into a hostile box could plant a command that fires on your next restart.

So the terminal puts a random token in an environment variable, OSC7577_TOKEN, for the first process in each pane. A program hashes its report plus that token and sends only the hash. Text from a log file or a remote server doesn't have the token, so its reports fail the check. The terminal also ignores reports whose time is too far from its own clock (the spec suggests 60 seconds), so replaying a recorded report goes stale fast.

The spec is honest about its limits. Programs running as the same user can read the token, and a sandboxed child that inherits it could register a command that later runs with your full rights. I like that they wrote this down instead of pretending the token solves everything. Resume is also "a hint, not a guarantee": the terminal decides whether to act, and Rex pairs it with opt-in trust rules.

Where it works today

Rex's docs list Claude Code as resuming through a hook Rex ships, and it comes back in the same conversation with the flags it was started with. Codex and OpenCode don't report yet. herdr's release notes say agents can now report their own resume command, and herdr reopens their exact session after a server restart.

My take: this is boring plumbing in the best way. People have dodged this for years by running tmux or screen inside their terminal, but a reboot still wipes that out too. One shared protocol beats every agent writing custom hooks for every terminal.

Here's a fun detail to end on. The spec deliberately uses a plain SHA-256 hash and not an HMAC, because the common way to compute an HMAC in a shell puts the token on the command line, where other users can see it. With a plain hash, the token goes into sha256sum through standard input.

So, would you trust your terminal to restart your programs for you?


Sources: Program Resume Protocol (OSC 7577) spec, Rex Session Restore docs, herdr releases, Mitchell Hashimoto on X.