Metadata-Version: 2.5
Name: cc-ghostty
Version: 0.7.0
Summary: Claude Code in Ghostty: restore crashed sessions as tabs, one repository per session
Project-URL: Homepage, https://toilal.github.io/cc-ghostty/
Project-URL: Repository, https://github.com/Toilal/cc-ghostty
Project-URL: Documentation, https://github.com/Toilal/cc-ghostty/tree/develop/docs
Project-URL: Changelog, https://github.com/Toilal/cc-ghostty/blob/develop/CHANGELOG.md
Project-URL: Issues, https://github.com/Toilal/cc-ghostty/issues
Author: Toilal
License-Expression: MIT
License-File: LICENSE
Keywords: claude,claude-code,ghostty,session-restore,terminal
Classifier: Environment :: Console
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Terminals :: Terminal Emulators/X Terminals
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# <img src="https://raw.githubusercontent.com/Toilal/cc-ghostty/develop/.claude-plugin/icon.png" alt="" width="40" align="top"> [cc-ghostty](https://toilal.github.io/cc-ghostty/)

**Your Claude Code sessions, at home in [Ghostty](https://ghostty.org).**

[![PyPI](https://img.shields.io/pypi/v/cc-ghostty?cacheSeconds=3600)](https://pypi.org/project/cc-ghostty/)
[![Python](https://img.shields.io/pypi/pyversions/cc-ghostty?cacheSeconds=3600)](https://pypi.org/project/cc-ghostty/)
[![CI](https://github.com/Toilal/cc-ghostty/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/Toilal/cc-ghostty/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/Toilal/cc-ghostty/blob/develop/LICENSE)

[![One prompt: each project in its own tab, its dev server in a pane on the right](https://toilal.github.io/cc-ghostty/media/cc-ghostty-demo.gif)](https://toilal.github.io/cc-ghostty/)

*One prompt opens each project in its own tab, its dev server in a pane beside it
([MP4](https://toilal.github.io/cc-ghostty/media/cc-ghostty-demo.mp4)).*

You run a dozen Claude Code sessions, one per tab, one per repository. Then Ghostty
crashes, the laptop reboots, or you simply call it a day, and they are all gone.
cc-ghostty brings them back in seconds, after a crash, the next morning or on Monday,
and keeps every session on the repository it belongs to.

*An unofficial plugin, not affiliated with the Ghostty project.*

## Features

### 🔁 Pick up where you left off: after a crash, the next morning, on Monday

One command reopens every session you had open **in its window, in its tab's place**,
resumed where it stopped: same conversation, same directory, same Claude account.

- **After a crash or a reboot:** everything Ghostty took down with it, back in seconds.
- **The next morning, or after the weekend:** quit Ghostty or shut the laptop down in
  the evening, and the next day the same command brings back yesterday's tabs, telling
  you where each session stopped (your last prompt, Claude's last answer) so you know
  what was next.

Sessions you closed on purpose stay closed, closing a tab or a window included, and
sessions still running elsewhere are left alone. Closed one by mistake? `--closed`
reopens the last tab or window you closed.

> *"My PC crashed, bring back everything I had open."*
>
> *"Good morning! Reopen yesterday's sessions."*
>
> *"Back from the weekend: where was I?"*

### 🪟 Tabs, panes and dev servers from one prompt

> *"Open each project in its own tab, with its dev server in a pane on the right."*

Claude writes the plan, cc-ghostty carries it out one tab at a time: the tab, then its
panes, then the next tab, and brings you back to the tab you asked from. Every tab and
pane it opens is remembered: a crash takes none of them away, dev servers included.

And when Claude is about to start something that keeps running, that you will want to
watch, or that needs you (a dev server, `tail -f`, a login, an interactive tool), it
asks first, in Claude Code's own question dialog:

> Where should `npm run dev` run?
> **Run it here** · **Pane on the right** · **Pane below** · **New tab**

The first answer is what Claude Code does without the plugin. Tired of the question?
The `run_commands` plugin option picks for you: `here`, `pane-right`, `pane-down`,
`pane-left`, `pane-up` or `tab` (`ask` by default). Say where in your request ("start
the server on the right") and that wins over both.

### 🧭 One repository, one session

Ask Claude for work in another repository and cc-ghostty steps in before anything is
touched:

> This is work on **api**, outside **web**. Where should it run?
> **Keep working here** · **Send to an open tab** · **Open a new tab**

Send the task to the Claude tab already open on that repository and it comes to the
front, or start a fresh session in a new tab: it keeps the session that sent it posted,
at each important step and once done. Keep working here and it stops asking about that repository. Your
sessions stay focused, and so do their contexts.

Every new session is named after its repository as it starts (`api`, then `api2`…),
so tabs, `/resume` and `cc-ghostty ps` tell them apart at a glance. Resumed and
restored sessions keep their own name.

### 🔔 See which session waits for you

A session that finishes its turn, asks you a question or needs a permission rings its
Ghostty tab: a 🔔 shows in the tab's title until you visit it, and the window asks for
attention. No sound unless you turned Ghostty's bell audio on. `cc-ghostty ps` shows
which sessions work and which wait, and `cc-ghostty next` takes you to the one that
has waited longest, questions first.

The `notify` plugin option chooses what rings: `all` (the default), `questions` (only
questions and permissions, not finished turns) or `off`.

### ⏭️ Walk your sessions

A band above every prompt lists every Claude session open in Ghostty, in the order of
its tabs, window by window, the panes of a tab together. The `order` option lists
them instead with the ones waiting for you first (`waiting`: questions and
permissions, then finished turns, each the longest waiting first, then the others),
or by when they started (`oldest`, `newest`). Each dot takes its session's color (a heavy orange `⭘` a question, a dotted green `◌` a finished
turn, nothing going on, a heavy red `⭘` at work, busy):

> [ghostty] ○●○ (Ctrl ←) ◀ api  web  docs ▶ (Ctrl →) &nbsp;&nbsp; *in an empty prompt*

Its buttons take you to the session before or after, and the dots show where you
stand. Typed in the empty prompt box, the arrows with Ctrl pick a session, or the
keys the `keyboard` option says:

| `ctrl-arrow` (default) | `shift-arrow`, `alt-arrow` | `pad`, `ctrl-pad`, `shift-pad`, `alt-pad` | Picks |
|---|---|---|---|
| Ctrl+← Ctrl+→ | Shift or Alt with ← → | `4` `6` | the session before or after, round the list |
| Ctrl+Home Ctrl+End, Alt+← Alt+→ | Shift or Alt with Home, End | `7` `9` | the first or the last |
| Ctrl+↑ | Shift or Alt with ↑ | `0` | the oldest question |
| Ctrl+↓ | Shift or Alt with ↓ | `1` | the next busy session (at work or asking), round them: to follow your agents; the band counts them from two |
|  |  | `5` | the automatic switches again (with the arrows, the band's ↻ Auto) |

With `ctrl-pad`, `shift-pad` or `alt-pad`, the keypad's keys need that modifier. The
band names the keys of the option's choice; the others type as ever. Ghostty binds
Alt with the digits to its tabs (`goto_tab`) and Ctrl+0 to `reset_font_size`, and with
Num Lock on, Shift turns the keypad's digits into arrows: unbind or pick another
choice if these do not reach Claude Code. Ghostty binds Shift with the arrows to `adjust_selection` and Shift
with Home and End to scrolling: with `shift-arrow`, unbind them in Ghostty's config
if they do not reach Claude Code (`keybind = shift+arrow_left=unbind`, …). Ctrl+Alt with the arrows never
reaches Claude Code: Ghostty moves between panes with
it, GNOME between workspaces. The band offers the questions in orange before its dots
(`? api, web (Ctrl ↑)`, the oldest first, three
named at most then `+N`, while one waits; once
you answer it, you go on to the next oldest one, and back where you were once
none is left, while a question you dismiss, or chat
about, keeps you there), its name
shown between the two buttons; hold one down to run along the list, and the tab
comes to the front once you let go. One typed as the band goes away is dropped, not
typed. Back and Next are greyed out when no other session is open. The `band` plugin
option set to `hint` puts it, as text, at the right end of the line under the prompt
(`(Ctrl ←) ◀ api  web  docs ▶ (Ctrl →)`, its dots on the row below, where Claude Code shows its modes, Back and Next greyed out
the same way): no line of its own, no buttons, the
keys walk it; set to `switches`, it shows only around an automatic switch.

#### Taken to them once you are idle

Turn on `auto_switch` (`all`, or `questions` for questions and permissions only; `off`
by default) and, once you stop typing for a few seconds (`auto_switch_delay`, 3), the
band counts down to the next session waiting for you, then takes you there:

> [ghostty] ●○ (Ctrl ←) ◀ Back  api  **web ▶ (Ctrl →)** ⠋ 5s &nbsp;&nbsp; *web waits for your answer · any key stays*

Any key or a mouse move calls it off, and a draft in the prompt keeps you where
you are. It never leaves a session that asks you something, never switches while
another application has the focus, and switches once per idle spell: the next waits
until you have done something and stopped again. A key pressed always counts as
being at work; the mouse only when it really moves, not when it is nudged. Once none
is left, it brings you back where the round started. Do nothing in the session it
took you to for 30 seconds and it takes you back to the one you were in: you did not
see it, so it rings again and waits for you.

Walking the band yourself, shown all the time, pauses the switches: while a session waits,
**(5) ↻ Auto** (or its key) switches again. Not now? `cc-ghostty waiting pause 1h`. The
switches need GNOME on Linux (or macOS) to tell that you are idle.

### 🗂️ All your sessions, one command away

```sh
cc-ghostty ps                 # every running session: name, account, state, repository
cc-ghostty focus api          # jump to its tab
cc-ghostty next               # jump to the session waiting for you
cc-ghostty waiting pause 1h   # no automatic switch for an hour
cc-ghostty close api2         # close its tab for good
cc-ghostty split right ~/api  # a new session in a pane on the right
cc-ghostty split down --run "npm run dev"   # or any command: a dev server, logs…
```

Stop a command run this way (Ctrl-C) and its tab stays, a shell with the command in
its history: Up brings it back, to run it again (bash and zsh).

Or just ask Claude: *"open `<project>` in a new tab"*, *"run the app in a pane on the
right"*, *"run the tests below"*, *"go to the api tab"*, *"close the dev server"*. The
plugin's skills know the commands, so Claude never has to read their help.

### 👥 Multi-account aware

Work and personal Claude accounts side by side (several `CLAUDE_CONFIG_DIR`)? Each
session is restored, listed and opened under its own account. A new Claude tab starts
on the account a new terminal in its directory would pick (claude-switch, direnv, a
shell hook) or, with the `same_account` plugin option, on the account of the session
opening it.

## Install

In Claude Code:

```
/plugin marketplace add Toilal/cc-ghostty
/plugin install ghostty@cc-ghostty
```

That's it: sessions started from now on are remembered (sessions already running can
still be found after a crash: *"restore my sessions"* falls back to scanning
transcripts). Then run `/ghostty:doctor` once: it checks your setup and, on Linux,
offers the one-line Ghostty config panes need.

For the shell commands too:

```sh
uv tool install cc-ghostty    # or: pipx install cc-ghostty
```

**Requirements:** a recent Claude Code (2.1.332+, for the mod that names sessions and
hands work over), Python 3.9+ as `python3` (standard library only; on macOS, the one that
comes with the Xcode Command Line Tools is enough), and

- **Linux:** Ghostty 1.4+ (GTK) and `gdbus`; for restoring tabs in their windows and
  order, the accessibility bus and PyGObject (`python3-gi`, `gir1.2-atspi-2.0`, already
  there on GNOME desktops);
- **macOS:** Ghostty 1.3+, driven through its AppleScript support: macOS asks once to
  let your terminal control Ghostty.

Updates come with releases: `/plugin marketplace update cc-ghostty`, then
`/plugin update ghostty@cc-ghostty`.

Outside Ghostty, restore prints the commands to run instead of opening tabs.

## What it runs, reads and stores

Everything stays on your machine: cc-ghostty makes no network request and sends
nothing anywhere.

- **Hooks.** `SessionStart`, `Stop` and `SessionEnd` run
  `python3 ${CLAUDE_PLUGIN_ROOT}/bin/cc-ghostty hook …`, which records the session (id,
  directory, `CLAUDE_CONFIG_DIR`, Claude's pid, Ghostty tab) and how it ended. The
  first two also start a background snapshot of Ghostty's windows and tab titles, at
  most every 20 seconds. A hook never fails a session: errors are swallowed.
- **The mod** (`hooks/register.ts`, loaded by `hooks/hooks.json`):
  - names each new session you start yourself after its repository, by running
    `/rename` (resumed and restored sessions keep theirs);
  - adds three tools, `hand_over`, `report_back` (a handed-over task's progress,
    questions and end, sent back to the session that handed it over) and `run_in_terminal`, whose descriptions tell Claude
    when to use them;
  - asks you before Edit, Write, NotebookEdit or Bash changes another repository
    (reading one is not asked about), and
    before Bash runs a command that keeps running or needs you (a dev server, a
    login); it never blocks a tool call when it fails;
  - records whether the session works, waits for an answer or finished its turn, as
    Claude Code tells it, ringing the tab's bell (the BEL character written to its
    terminal) when it starts waiting;
  - shows the band of the sessions waiting for you above the prompt;
  - keeps your last prompt in memory, to hand it over to the Claude session you pick
    (`$.session.send`, local);
  - runs `bin/cc-ghostty` for the machine work (finding sessions, opening tabs, panes).
- **What it reads:** how long you have been idle (GNOME's idle monitor, IOKit on
  macOS) and the focused Ghostty window's title, while a session waits for
  you; Claude Code's live sessions (`<config dir>/sessions/*.json`), the
  transcripts of the sessions it lists or restores (titles, and the last prompt and
  reply for "where you stopped"), the account email in `.claude.json`, and the
  environment of Claude processes (their Ghostty tab, through `GHOSTTY_SURFACE_ID`).
- **What it stores:** session, tab, layout and session state records under
  `~/.local/state/cc-ghostty/`. Records older than 14 days are deleted, and only the
  last 50 layout snapshots are kept.
- **What it runs:** `ghostty`, `gdbus` and the system `python3` (accessibility tree)
  on Linux, `osascript` and `ioreg` (idle time) on macOS, and `claude` to start or resume sessions in the tabs
  it opens.
- **What it changes:** nothing in Claude Code's settings or permissions.
  `cc-ghostty setup` (offered by `/ghostty:doctor`, on Linux) adds one `config-file`
  include line to Ghostty's config, so panes can run a command.

## Learn more

- [Website](https://toilal.github.io/cc-ghostty/): the demo video and the features at a glance
- [Command line reference](https://github.com/Toilal/cc-ghostty/blob/develop/docs/cli.md)
- [How it works](https://github.com/Toilal/cc-ghostty/blob/develop/docs/how-it-works.md):
  what counts as interrupted, the hand-over, driving Ghostty on Linux and macOS
- [Development](https://github.com/Toilal/cc-ghostty/blob/develop/docs/development.md):
  setup, running your working copy as the plugin, releases
- [Changelog](https://github.com/Toilal/cc-ghostty/blob/develop/CHANGELOG.md)

> **Status:** early. Daily-driven on Linux; macOS support is new: issues and ideas are
> welcome.

## License

MIT
