| name | gtmux-cli |
| description | Control the gtmux canvas layout and terminals from inside a gtmux pane via the `gtmux` CLI. Use when running inside a gtmux terminal, or when the user mentions gtmux, canvas panels/panes, layout, or driving another terminal panel. Covers layout move/resize/create/delete, figure & note editing, group, align, path connections, terminal spawn/mount/read/send, workspace & session, fs upload. |
gtmux CLI
gtmux ํฐ๋ฏธ๋ ์์ AI agent ๊ฐ gtmux CLI ๋ก canvas layout ๊ณผ terminal ์ ์ ์ดํ๋ค. CLI ๋ live ์๋ฒ์ HTTP API ๋ฅผ ๊ฒฝ์ ํ๋ฉฐ layout(web state)์ ์ ์ดํ๊ณ (ADR-0053), ๋ค๋ฅธ terminal ์ ๋ด์ฉ์ ์ฝ๊ณ command ๋ฅผ ๋ณด๋ผ ์ ์๋ค(ADR-0054). ์ฌ์ฉ์๋ ๋ธ๋ผ์ฐ์ canvas ์์ ์ด ์กฐ์์ ์ค์๊ฐ์ผ๋ก ๋ณธ๋ค.
0. ์ ์
gtmux binary ๊ฐ PATH ์ ์์ด์ผ ํ๋ค.
- ์๋ฒ๊ฐ ๋ ์์ด์ผ ํ๋ค. ์ธ์คํด์ค๊ฐ ์ฌ๋ฟ์ด๋ฉด
GTMUX_SERVER_INSTANCE env ๋๋ --instance.
- ์ธ์ฆ์ ์๋(๋ก์ปฌ token ํ์ผ โ Bearer). ๋ณ๋ ์ค์ ๋ถ์.
- ์ด ๋ฌธ์ ์์ฒด๋ฅผ CLI ๋ก ๋ค์ ์ฝ์ผ๋ ค๋ฉด
gtmux skill(์ ์ฒด) / gtmux skill --section <n>.
1. ์๊ธฐ ์๋ณ (์ด๋ panel/session ์ด "๋"์ธ๊ฐ)
gtmux ๊ฐ spawn ํ ํฐ๋ฏธ๋์ ์ฃผ์
๋๋ env:
| env | ์๋ฏธ |
|---|
GTMUX_TERMINAL_ID | ์ด ํฐ๋ฏธ๋์ UUID = canvas ์ ๋ด terminal item id. gtmux layout move $GTMUX_TERMINAL_ID โฆ ์ฒ๋ผ ๋ฐ๋ก ์ฌ์ฉ |
GTMUX_CANVAS_SESSION | ๋ด๊ฐ ์ํ canvas session ์ด๋ฆ. --session ์๋ต ์ ๊ธฐ๋ณธ๊ฐ |
GTMUX_SERVER_INSTANCE | ์๋ฒ ์ธ์คํด์ค๋ช
(canvas session ์๋ โ ํผ๋ ๊ธ์ง) |
env ๊ฐ ์์ผ๋ฉด gtmux layout list ๋ก ํํฉ์ ๋ณด๊ณ label ๋ก ์ถ์ ํ๋, ์๊ธฐ ์์ ์ ๋ํ ํ๊ดด์ ์กฐ์์ ํผํ๋ค.
2. ๋ช
๋ น ํ๋ฉด
์กฐํ (--json ์ง์):
gtmux layout list # ์ ์ฒด item ์์ฝ: id/type/label/geometry/visibility/locked/z
gtmux layout get <target> # ๋จ๊ฑด ์์ธ (--json ์ payload ์ ์ฒด)
gtmux layout connections <target> # path ๋ก ์ฐ๊ฒฐ๋ ์๋ item ๋ชฉ๋ก
gtmux terminal ls # ์๋ฒ ์ ์ฒด terminal pool (attach ํํฉ ํฌํจ)
gtmux workspace get --session <name>
layout mutation (<target> = UUID ๋๋ label ์ ํ์ผ์น):
gtmux layout move <target> --x <f> --y <f>
gtmux layout resize <target> --w <f> --h <f>
gtmux layout show|hide|minimize|restore <target>
gtmux layout label <target> <text>|--clear
gtmux layout raise|raise-top|lower|lower-bottom <target>
gtmux layout edit <target> --set k=v ... | --json '<partial payload>'
gtmux layout create <type> [--x --y --w --h] [--set ...|--json ...] # text/note/rect/ellipse/line/free_draw/image/document/file_path/snippets/caption/path
gtmux layout delete <target> [--kill-terminal] [--force]
gtmux layout group create <t1> <t2> ... [--label <s>] | ungroup <g> | reparent <t> --parent <g|root>
gtmux layout align <mode> <t1> <t2> ... # left/right/top/bottom/center-h/center-v/distribute-h/distribute-v
gtmux layout batch --json '<ops[]>' # ์์์ ์ผ๊ด ์ ์ฉ
terminal / workspace / session / fs:
gtmux terminal spawn [--x --y --w --h] # ์ terminal panel (headless ์๊ฒฐ, ๊ธฐ๋ณธ shell)
gtmux terminal mount <uuid> [--x --y] # pool ์ ๊ธฐ์กด terminal ์ canvas ์ ๋ค์ ์ฌ๋ฆผ
gtmux terminal unmount <target> # panel ๋ง ์ ๊ฑฐ, terminal ์ pool ์๋ฅ
gtmux terminal kill <target> # process ์ข
๋ฃ
gtmux terminal read <target> [--tail N] [--raw] # ํฐ๋ฏธ๋ ์ถ๋ ฅ ์ฝ๊ธฐ (๊ธฐ๋ณธ ANSI strip ํ
์คํธ, --raw ๋ ์๋ณธ ๋ฐ์ดํธ)
gtmux terminal send <target> <text> [--no-enter] # ์
๋ ฅ ์ฃผ์
(๊ธฐ๋ณธ ๋ค์ \n โ ๋ช
๋ น ์คํ; --no-enter ๋ ๊ฐํ ์์ด)
gtmux terminal send <target> --bytes <hex> # ์ ์ด ์ํ์ค (03=Ctrl-C, 1b5b41=Up)
gtmux workspace set <path> --session <name>
gtmux session create <name> [--workspace <p>] [--yes|--password <p>] # ์ถ๊ฐ ์ธ์ฆ ๊ฒ์ดํธ
gtmux session delete <name> [--yes|--password <p>]
gtmux fs upload <src-path> --dir <ws-relative> --session <name> # workspace ๋ก ํ์ผ ๋ฐ์
3. ๊ท์น (์๋ฐ ์ ์๋ฒ๊ฐ ๊ฑฐ๋ถ)
- locked item ์ ๊ธฐ๋ณธ ๊ฑฐ๋ถ(409) โ ์ฌ์ฉ์๊ฐ ์ ๊ทผ ๊ฒ.
--force ๋ ์ฌ์ฉ์๊ฐ ๋ช
์ ์ง์ํ์ ๋๋ง.
- z ๋ 4์ก์
๋ง(์์ z ๊ฐ ์ง์ ๋ถ๊ฐ).
maximized/viewport/selection ์ CLI ๋ก ์ ์ด ๋ถ๊ฐ.
- terminal item ์
create ๋ถ๊ฐ โ terminal spawn/mount ์ฌ์ฉ.
- image/document ์
path ๋ workspace ์๋๊ฒฝ๋ก + ์ค์กด ํ์ผ์ด์ด์ผ ํจ. ๋ก์ปฌ ํ์ผ์ fs upload ๋ก ๋จผ์ ๋ฐ์
ํ ์ฐธ์กฐ (2-step).
- session-level ๋ช
๋ น(workspace/session)์ session ๋ช
์ ํ์. session create/delete ๋ ์ธ์ฆ ๊ฒ์ดํธ(password ์ค์ ์
--password, ๋ฏธ์ค์ local ์ --yes).
- ์๋ฌ๋ exit code โ 0 + stderr ํ ์ค(machine-readable code). label ์ด ๋ชจํธํ๋ฉด(0๊ฑด/๋ณต์) ํ๋ณด๊ฐ ๋์ด๋๋ค โ UUID ๋ก ์ฌ์๋.
4. ํจํด
- ์ํํ(status board):
create note --set title="์์
์ํ" ํ ์งํ ์ํฉ์ edit ๋ก ๊ฐฑ์ โ ์ฌ์ฉ์๊ฐ canvas ์์ ์ค์๊ฐ ๋ชจ๋ํฐ๋ง. ์๋ฃ/์คํจ๋ labelยท์์ผ๋ก๋ ํ์.
- ๊ตฌ์ฑ ์์
์ batch: ์ฌ๋ฌ panel ์ ๋ฐฐ์นยท์ ๋ ฌํ ๋๋ ๊ฐ๋ณ ๋ช
๋ น ๋ฐ๋ณต ๋์
align ๋๋ batch --json (์์ ์ ์ฉ, ํ๋ฉด ๊น๋นก์ ์ต์).
- ์ฐ๊ฒฐ ํํ: ๊ด๋ จ component ๋
create path --json '{"from":{"kind":"connected","item_id":"...","anchor":"E",...},...}' ๋ก ์ฐ๊ฒฐํ๊ณ , connections ๋ก ๊ทธ๋ํ๋ฅผ ์ญ์กฐํ.
- worker ํฐ๋ฏธ๋:
terminal spawn ์ผ๋ก ํ์ ํฐ๋ฏธ๋์ ๋ง๋ค๊ณ , terminal read/terminal send ๋ก ์ถ๋ ฅ์ ์ฝ๊ณ ๋ช
๋ น์ ์ฃผ์
. ํ๋ฆ: ๋ค๋ฅธ ํจ๋์ terminal read <other> ๋ก ๊ด์ฐฐ โ ๊ตฌ์ํ ์์
์ terminal send <other> "ls" ๋ก ์คํ. ๋จ read ๋ raw ring(128KiB drop-oldest) ์ค๋
์ท์ด๋ผ ๊ธด ์ถ๋ ฅ์ ์๋ถ๋ถ์ ์ ์ค๋๊ณ ANSI ๊ฐ ์์ธ๋ค(๊ธฐ๋ณธ ์ถ๋ ฅ์ CLI-side ANSI strip). claude/codex ๋ํํ TUIยทvim ๊ฐ์ full-screen ์ฌ๊ทธ๋ฆฌ๊ธฐ ํ๋ฉด์ raw ๊ฐ ์ฌ๊ทธ๋ฆฌ๊ธฐ ์คํธ๋ฆผ์ด๋ผ ๊ฑฐ์ ๋ฌด์๋ฏธ โ ์์ ์บก์ฒยท๋ช
๋ น ์๋ฃ ์ ํธ๊ฐ ํ์ํ๋ฉด headless(claude -p --output-format stream-json, codex exec --json)๋ฅผ ๊ทธ ํฐ๋ฏธ๋์์ ๋๋ ค NDJSON ์ ์ง์ ํ์ฑํ๋ผ.
5. ํ์ง ๋ง ๊ฒ
- layout JSON ํ์ผ ์ง์ ํธ์ง(์๋ฒ lock/ETag/broadcast ์ฐํ โ ํญ์ CLI/HTTP ๊ฒฝ์ ).
- ์ฌ์ฉ์๊ฐ ๋๋๊ทธ ์ค์ธ item ์ ์ฐ์ mutate(์ถฉ๋ ์ last-writer-wins ๋ก ์๋ก ๋ฎ์ด์).
- ์๊ธฐ ์์ (
$GTMUX_TERMINAL_ID)์ delete --kill-terminal / terminal kill โ ์๊ธฐ ํ๋ก์ธ์ค๊ฐ ์ฃฝ๋๋ค.
- ์๊ธฐ ์์ (
$GTMUX_TERMINAL_ID)์ terminal send โ ์๊ธฐ ์
๋ ฅ ์คํธ๋ฆผ ์ค์ผ(self-injection). send ๋์์ ํญ์ ๋ค๋ฅธ terminal.
terminal read ํด๋ง๋ง์ผ๋ก ํ์ ์์
"์๋ฃ" ํ์ โ raw ring ์ ์๋ฃ ์ ํธ๊ฐ ์๊ณ ์์ค์ฑ์ด๋ผ ์ํ ์ถ์ธก์ด ์ด๊ธ๋๋ค. ์๋ฃ ํ์ ์ด ํ์ํ๋ฉด ยง4 ์ headless NDJSON ๊ฒฝ๋ก.