Expand description
Rust client for the iTerm2 scripting API.
Communicates over WebSocket + Protobuf to control iTerm2 windows, tabs, and sessions programmatically. Covers all 34 operations in the iTerm2 API.
§Quick start
use iterm2_client::{App, Connection};
#[tokio::main]
async fn main() -> iterm2_client::Result<()> {
let conn = Connection::connect("my-app").await?;
let app = App::new(conn);
let result = app.list_sessions().await?;
let session = &result.windows[0].tabs[0].sessions[0];
session.send_text("echo hello\n").await?;
Ok(())
}§Architecture
Low-level: Connection::call() sends raw protobuf messages. Use with
the request module builders for full control.
High-level: App, Window, Tab, and Session wrap
Arc<Connection> and provide ergonomic methods with status checking.
Re-exports§
pub use app::App;pub use connection::Connection;pub use error::Error;pub use error::Result;pub use session::Session;pub use tab::Tab;pub use window::Window;
Modules§
- app
- High-level application entry point. High-level entry point for the iTerm2 API.
- auth
- Authentication: credential resolution from env vars or osascript. Authentication for the iTerm2 API.
- connection
- Core connection: request-response matching and notification dispatch. Core connection to iTerm2.
- error
- Error types for all operations. Error types for iTerm2 client operations.
- notification
- Notification streams with typed filtering. Notification streams with typed filtering.
- proto
- Generated protobuf types from iTerm2’s
api.proto. - request
- Request builders for all 34 iTerm2 API operations.
- session
- High-level session handle. High-level handle to an iTerm2 session (terminal pane).
- tab
- High-level tab handle. High-level handle to an iTerm2 tab.
- transport
- WebSocket transport (TCP and Unix socket). WebSocket transport for connecting to iTerm2.
- validate
- Input validation helpers.
- window
- High-level window handle. High-level handle to an iTerm2 window.