Communitygithub.com

cli-anything-iterm2

提供 cli-anything-iterm2 指令——這是唯一能實際傳送文字到 iTerm2 工作階段、讀取即時終端機輸出與捲動歷史、管理視窗/分頁/分割窗格、執行 tmux -CC 工作流程、同步廣播至多個窗格、顯示 macOS 對話框,以及讀寫 iTerm2 偏好設定的方式。包含「app snapshot」——主要的導向指令,可回傳每個工作階段的完整資訊。

cli-anything-iterm2 是什麼?

cli-anything-iterm2 是一個專為 AI 代理程式設計的狀態化 CLI 工具,用於控制 macOS 上的 iTerm2 終端機。它透過 WebSocket 與 iTerm2 的 Python API 通訊,提供對終端機工作階段的完整讀寫存取,包括傳送文字、讀取螢幕內容與捲動歷史、管理視窗與分頁佈局、以及執行 tmux -CC 工作流程。此工具的獨特優勢在於其「app snapshot」指令,可以一次回傳所有工作階段的名稱、當前目錄、前景程序、使用者定義角色標籤以及最後一行的輸出,讓代理程式在接觸現有工作區時能快速建立情境意識。cli-anything-iterm2 支援在 Cursor、Claude Code 等 AI 代理程式環境中使用,並提供完整的 JSON 輸出模式以確保機器可讀性,同時具備 REPL 模式以維持指令間的情境。

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

在你喜歡的 AI 中提問

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

說明文件

cli-anything-iterm2 是做什麼的?

用於 iTerm2 的狀態化 CLI 工具。透過 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 指令(啟動、傳送、分頁、建立視窗、set-visible)
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

>-

相關技能