use-ghostty
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUse Ghostty
使用 Ghostty
Ghostty (1.3+ on macOS) ships an AppleScript dictionary. wraps it so you can see and drive the user's real panes by id. Every call is a plain shell command and takes well under a second.
scripts/ghostty.jsbash
G=scripts/ghostty.js # resolve against this skill's folder; it is executable
$G ls # id w<window>:t<tab> flags title cwdls>*$G read 481aw1:t2Ghostty(macOS 上 1.3+)附带一个 AppleScript 字典。 对其进行了封装,因此可以按 id 查看并控制用户真实的窗格。每次调用都是普通的 shell 命令,耗时远少于一秒。
scripts/ghostty.jsbash
G=scripts/ghostty.js # resolve against this skill's folder; it is executable
$G ls # id w<window>:t<tab> flags title cwdls>*$G read 481aw1:t2Find the right pane first
先找到正确的窗格
- Identify panes by title and cwd from . Claude Code and most shells keep the title current (
ls,✳ <session name>).user@host:dir - Your own pane is one of them. It is usually the one whose title is this session's name. Never or
sendinto it, and never close it.key - When two panes could match, ask the user which one. Do not guess before typing into a pane.
- 通过 中的标题和 cwd 识别窗格。Claude Code 和大多数 shell 会持续更新标题(
ls、✳ <session name>)。user@host:dir - 你自己的窗格也在其中。 通常,它的标题就是当前会话的名称。绝不要向它 或
send,也不要关闭它。key - 如果可能有两个窗格匹配,请询问用户是哪一个。在向窗格输入内容前不要猜测。
Read
读取
bash
$G read <id> # visible screen
$G read <id> --all --tail 200 # scrollback + screen, last 200 lines
$G wait <id> 'PASS|FAIL' --timeout 120 # poll the screen until the regex matches, prints itGhostty can only dump a pane through , which puts a temp path on the clipboard. The script snapshots every clipboard item and type first and restores them after, then deletes the temp file. If the user copies something during that half second, it can be lost.
write_*_file:copybash
$G read <id> # visible screen
$G read <id> --all --tail 200 # scrollback + screen, last 200 lines
$G wait <id> 'PASS|FAIL' --timeout 120 # poll the screen until the regex matches, prints itGhostty 只能通过 导出窗格内容,这会将临时路径放到剪贴板。脚本会先快照剪贴板中的每个条目及其类型,随后恢复这些条目,再删除临时文件。如果用户恰好在这半秒内复制了内容,该内容可能会丢失。
write_*_file:copyAct
操作
bash
$G send <id> 'make test' --enter # types as a paste, then presses enter
$G key <id> c --mods control # Ctrl-C; keys: enter, escape, tab, up, a, ...
$G split <id> right --cwd ~/repo --cmd 'npm run dev' --wait-after # prints new pane id
$G tab --near <id> --cwd ~/repo # new tab in that pane's window, prints new pane id
$G window --input $'git status\n' # new window, initial input typed after launch
$G focus <id>
$G close <id> # also close-tab <id>, close-window <id>
$G action <id> <ghostty-action> # any keybind action, e.g. clear_screen, toggle_split_zoom--cmd--wait-after--input $'cmd\n'bash
$G send <id> 'make test' --enter # types as a paste, then presses enter
$G key <id> c --mods control # Ctrl-C; keys: enter, escape, tab, up, a, ...
$G split <id> right --cwd ~/repo --cmd 'npm run dev' --wait-after # prints new pane id
$G tab --near <id> --cwd ~/repo # new tab in that pane's window, prints new pane id
$G window --input $'git status\n' # new window, initial input typed after launch
$G focus <id>
$G close <id> # also close-tab <id>, close-window <id>
$G action <id> <ghostty-action> # any keybind action, e.g. clear_screen, toggle_split_zoom--cmd--wait-after--input $'cmd\n'Rules
规则
- Read before you type. Run and check that the pane is at the prompt you expect. A pane running Claude, a REPL,
read <id> --tail 20, or an editor takes your text as input to that program.less - Closing is instant. ,
closeandclose-tabkill running processes with no confirmation. Close only panes you created in this session, or ones the user named.close-window - Verify by reading back. After , use
sendorwaitto confirm what happened, and report what the pane showed.read - The first call may trigger a macOS Automation prompt ("allow <terminal> to control Ghostty"). The user has to accept it once.
- 输入前先读取。 运行 ,确认窗格正处于预期的提示符。正在运行 Claude、REPL、
read <id> --tail 20或编辑器的窗格会把你的文本当作该程序的输入。less - 关闭会立即生效。 、
close和close-tab会终止正在运行的进程,且不会要求确认。只关闭本次会话中创建的窗格,或用户明确指定的窗格。close-window - 通过回读进行验证。 执行 后,使用
send或wait确认发生了什么,并报告窗格显示的内容。read - 首次调用可能会触发 macOS Automation 权限提示(“允许 <terminal> 控制 Ghostty”)。用户需要接受一次。