| Crates.io | tuiw |
| lib.rs | tuiw |
| version | 0.1.2 |
| created_at | 2026-01-17 18:07:13.018722+00 |
| updated_at | 2026-01-17 18:56:28.615626+00 |
| description | TUI applications wrapper with tmux for headless operation |
| homepage | |
| repository | https://github.com/conao3/rust-tuiw |
| max_upload_size | |
| id | 2050884 |
| size | 557,444 |
![]()
TUI applications wrapper with tmux for headless operation.
rust-tuiw enables headless interaction with TUI (Terminal User Interface) applications by wrapping them with tmux. This allows for programmatic control and automation of interactive terminal applications.
The application operates in two modes:
On first invocation, if no daemon is running, the process automatically starts as a daemon. Subsequent invocations act as clients.
┌─────────────────────────────────────────────────────────┐
│ Client │
│ (GraphQL Client) │
└──────────────────────┬──────────────────────────────────┘
│ GraphQL over HTTP
│ SSE for subscriptions
┌──────────────────────▼──────────────────────────────────┐
│ Daemon │
│ (GraphQL Server) │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Session Management (in-memory) │ │
│ │ - Session ID generation │ │
│ │ - CWD tracking │ │
│ │ - Multiple session support │ │
│ └─────────────────────┬───────────────────────────┘ │
│ │ │
│ ┌─────────────────────▼───────────────────────────┐ │
│ │ Tmux Wrapper │ │
│ │ - Session creation │ │
│ │ - Key input injection │ │
│ │ - Output capture (capture-pane) │ │
│ │ - Change detection for SSE │ │
│ └─────────────────────┬───────────────────────────┘ │
└────────────────────────┼───────────────────────────────┘
│
┌────────▼────────┐
│ Tmux Sessions │
│ ┌──────────┐ │
│ │ TUI │ │
│ │ App │ │
│ └──────────┘ │
└─────────────────┘
createSession(command: String!, cwd: String!): SessionIDsendKeys(sessionId: SessionID!, keys: String!): BooleancloseSession(sessionId: SessionID!): BooleanlistSessions: [Session!]!getOutput(sessionId: SessionID!): String!getSessionStatus(sessionId: SessionID!): SessionStatus!screenChanges(sessionId: SessionID!): String! (via SSE)Each session maintains:
Multiple TUI applications can run simultaneously, each in its own session.
Claude Code currently lacks a headless interaction mode. By wrapping Claude Code with rust-tuiw, you can:
Since rust-tuiw works with any TUI application, it enables automation for:
nix develop for development environmentgit clone https://github.com/conao3/rust-tuiw.git
cd rust-tuiw
cargo build --release
The binary will be available at target/release/tuiw.
Alternatively, install via cargo:
cargo install tuiw
Create a new TUI session by specifying the command to run:
tuiw create "bash"
This will output a session ID (UUID format):
Session created: a1b2c3d4-e5f6-7890-abcd-ef1234567890
You can also specify a working directory:
tuiw create "vim" --cwd /path/to/project
View all active sessions:
tuiw list
Output:
Sessions:
a1b2c3d4-e5f6-7890-abcd-ef1234567890 - bash (/home/user)
Send keyboard input to a session:
tuiw send a1b2c3d4-e5f6-7890-abcd-ef1234567890 "echo hello"
tuiw send a1b2c3d4-e5f6-7890-abcd-ef1234567890 "Enter"
Capture the current screen content:
tuiw output a1b2c3d4-e5f6-7890-abcd-ef1234567890
Check if a session is running:
tuiw status a1b2c3d4-e5f6-7890-abcd-ef1234567890
Terminate a session:
tuiw close a1b2c3d4-e5f6-7890-abcd-ef1234567890
# Create a vim session
SESSION_ID=$(tuiw create "vim" | grep -oE '[0-9a-f-]{36}')
# Open a file
tuiw send $SESSION_ID ":e test.txt"
tuiw send $SESSION_ID "Enter"
# Enter insert mode and type
tuiw send $SESSION_ID "i"
tuiw send $SESSION_ID "Hello, World!"
# Save and quit
tuiw send $SESSION_ID "Escape"
tuiw send $SESSION_ID ":wq"
tuiw send $SESSION_ID "Enter"
# Close session
tuiw close $SESSION_ID
Subscribe to screen changes via Server-Sent Events:
curl -N http://127.0.0.1:50051/sse/<session-id>
This streams output whenever the screen content changes.
The daemon exposes a GraphQL API at http://127.0.0.1:50051/graphql:
curl -X POST http://127.0.0.1:50051/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "query { listSessions { id command cwd } }"
}'
Daemon not starting:
Session not found:
rust-tuiw listKeys not being sent:
rust-tuiw statusSee Makefile for available commands:
make build - Build the projectmake run - Run the applicationmake test - Run testsmake check - Run cargo checkmake clippy - Run clippy lintsmake fmt - Format codeApache-2.0