Communitygithub.com

cli-anything-iterm2-ctl

提供 cli-anything-iterm2 指令,這是唯一能真正傳送文字到 iTerm2 工作階段、讀取即時終端輸出與回滾歷史、管理視窗/分頁/分割面板、執行 tmux -CC 工作流程、廣播到多個面板、顯示 macOS 對話框,以及讀寫 iTerm2 偏好的方式。包含 `app snapshot`——主要導向指令,可回傳每個工作階段的狀態。

cli-anything-iterm2-ctl 是什麼?

此技能提供一個有狀態的命令列工具 `cli-anything-iterm2`,用於以程式化方式控制 iTerm2 終端模擬器。它透過 WebSocket 使用 iTerm2 的 Python API,讓 AI 代理能夠在現有或新的終端工作階段中傳送文字、讀取螢幕內容、管理分割面板,以及操作視窗與分頁。此技能支援多個指令群組,包括 `app`(快照、變數、對話框)、`session`(輸入、輸出、分割)、`window`/`tab`(佈局管理)、`tmux`(完整的 tmux -CC 整合)、`broadcast`(同步按鍵輸入)、`pref`(讀寫偏好設定)等。其關鍵特性是 `app snapshot` 指令,能為所有工作階段回傳名稱、目錄、前景程序、使用者角色標籤及最後輸出行,讓代理能快速掌握現有工作區的全貌。此工具特別適合在開發者工作流程中自動執行重複性任務、監控日誌、管理多面板開發環境,以及透過 REPL 模式維持指令間的工作階段上下文。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/HKUDS/CLI-Anything/tree/main/skills/cli-anything-iterm2-ctl

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

cli-anything-iterm2

有狀態的 iTerm2 命令列工具。透過 WebSocket 使用 iTerm2 Python API 控制執行中的 iTerm2 程序。

先決條件

  1. macOS + iTerm2 正在執行:brew install --cask iterm2
  2. 啟用 Python API:iTerm2 → 偏好設定 → 一般 → Magic → 啟用 Python API
  3. 安裝:pip install cli-anything-iterm2(或從原始碼執行 pip install -e .)

基本語法

cli-anything-iterm2 [--json] <group> <command> [OPTIONS] [ARGS]

始終使用 --json 以取得機器可讀的輸出(代理使用時必需)。

指令群組

群組用途
app應用程式狀態、工作區快照、上下文管理、應用層級變數、模態對話框、檔案面板
window建立、列出、關閉、調整大小、全螢幕視窗
tab建立、列出、關閉、啟用分頁;依方向導航分割面板
session傳送文字、注入原始位元組、讀取螢幕、完整回滾、分割面板、提示符偵測
profile列出設定檔、取得設定檔詳細資訊、列出/套用色彩預設
arrangement儲存與還原視窗佈局
tmux完整的 tmux -CC 整合:引導、連線、視窗、指令
broadcast透過廣播域同步多個面板的按鍵輸入
menu以程式化方式呼叫任何 iTerm2 選單項目
pref讀寫全域 iTerm2 偏好設定;列出所有有效鍵;tmux 設定

在現有工作區中導向

當你進入一個包含現有面板的工作階段,且需要了解正在執行什麼,而不需讀取每個面板的完整螢幕內容時,請使用 app snapshot:

cli-anything-iterm2 --json app snapshot

回傳所有視窗中每個工作階段的名稱、目前目錄、前景程序、user.role 標籤及最後可見輸出行。

命名慣例——在設定工作區時為面板加上標籤,以便日後找到它們:

cli-anything-iterm2 session set-var user.role "api-server"
cli-anything-iterm2 session set-var user.role "log-tail"
cli-anything-iterm2 session set-var user.role "editor"

app snapshot 會將這些角色與程序和路徑一併顯示,讓你一次呼叫就能掌握完整樣貌。

典型的代理工作流程

# 1. 導向——快照每個工作階段:名稱、路徑、程序、角色、最後輸出行
cli-anything-iterm2 --json app snapshot

# 2. 建立上下文(儲存後續指令所需的視窗/分頁/工作階段 ID)
cli-anything-iterm2 app current

# 3. 互動——設定上下文後無需再指定 --session-id
cli-anything-iterm2 session send "git status"
cli-anything-iterm2 --json session scrollback --tail 200 --strip

# 4. 建立多面板工作區——為面板加上標籤,讓快照後續能識別它們
cli-anything-iterm2 session split --vertical --use-as-context
cli-anything-iterm2 session send "python3 -m http.server 8000"
cli-anything-iterm2 session set-var user.role "http-server"

參考檔案

僅讀取任務所需的檔案——每個檔案都是一個單一狹義的主題(約 10–30 行):

檔案何時需要讀取
references/session-io.md傳送文字、注入位元組、讀取螢幕/回滾、取得選取內容
references/session-control.md分割面板、啟用/關閉工作階段、調整大小、重新命名、工作階段變數
references/session-shell-integration.mdwait-prompt、wait-command-end、get-prompt;可靠的 send→wait→read 模式
references/layout-window-tab.md建立/關閉/調整視窗與分頁大小、導航分割面板
references/layout-arrangement.md儲存與還原視窗佈局
references/app-context.md快照(導向)、狀態、上下文管理、應用程式變數、模態對話框、檔案面板
references/profile-pref.md設定檔列表/取得/預設、偏好設定讀寫、tmux 偏好設定捷徑
references/broadcast-menu.md將按鍵輸入廣播到多個面板、呼叫選單項目
references/tmux-commands.md所有 tmux CLI 指令(引導、傳送、分頁、建立視窗、設定可見)
references/tmux-guide.md完整的 tmux -CC 工作流程、面板→工作階段 ID 對應
references/json-session.md工作階段、視窗、分頁、螢幕、回滾、注入的 --json 結構定義
references/json-tmux-app.mdtmux、應用程式對話框、偏好設定、錯誤的 --json 結構定義

REPL 模式

不帶參數執行以啟動互動式 REPL,可在指令間維持上下文:

cli-anything-iterm2

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cli-anything-adguardhome

>-

cli-anything-anygen

>-

cli-anything-audacity

>-

cli-anything-blender

>-

cli-anything-browser

Browser automation CLI using DOMShell MCP server. Maps Chrome

cli-anything-calibre

>-

cli-anything-ccswitch

CLI interface for CC Switch — manage AI coding tool configurations from the terminal

cli-anything-chromadb

>-

cli-anything-cloudanalyzer

Command-line interface for CloudAnalyzer — Agent-friendly harness for CloudAnalyzer, a QA platform for mapping, localization, and perception outputs. Supports 27 commands across 8 groups: point cloud evaluation, trajectory evaluation, ground segmentation QA, config-driven quality gates, baseline evolution, processing, visualization, and interactive REPL.

cli-anything-cloudcompare

Command-line interface for CloudCompare — Agent-friendly harness for CloudCompare, the open-source 3D point cloud and mesh processing software. Supports 41 commands across 9 groups: project management, session control, point cloud operations (subsample, filter, segment, analyze), mesh operations, distance computation (C2C, C2M), transformations (ICP, matrix), export (LAS/LAZ/PLY/PCD/OBJ/STL/E57), and interactive REPL.

cli-anything-comfyui

>-

cli-anything-dify-workflow

Wrapper for the Dify workflow DSL CLI. Create, inspect, validate, edit, and export Dify workflow files through a CLI-Anything harness.

cli-anything-drawio

>-

cli-anything-eez-studio

Use EEZ Studio from the command line: inspect and modify native .eez-project files, edit LVGL screens/widgets, manage SCPI commands, and invoke the real EEZ Studio backend for LVGL builds.

cli-anything-eth2-quickstart

>-

cli-anything-exa

>-

cli-anything-firefly-iii

Firefly III CLI - Personal finance management via CLI-Anything

cli-anything-freecad

Complete CLI harness for FreeCAD parametric 3D CAD modeler (258 commands). Covers ALL workbenches: Part (29 primitives + boolean + mirror + loft + sweep), Sketcher (26 cmds: geometry + constraints + editing), PartDesign (38 cmds: pad/pocket/groove/fillet/chamfer/patterns/hole/datum), Assembly (11 cmds), Mesh (16 cmds), TechDraw (15 cmds: views + dimensions + PDF/SVG), Draft (33 cmds: 2D shapes + arrays + transforms), FEM (12 cmds), CAM/CNC (10 cmds), Surface (6 cmds), Spreadsheet (7 cmds), Import (13 formats), Export (17 formats), Measure (12 cmds), Materials (21 presets). Headless FreeCAD export to STEP/IGES/STL/OBJ/DXF/PDF/glTF/3MF.

cli-anything-gimp

>-

cli-anything-godot

>-

相關技能