TUIOS Tape is a domain-specific language (DSL) for automating terminal window management workflows. Tape scripts allow you to record, replay, and test complex TUIOS interactions programmatically.
- Basic Syntax
- Commands Reference
- Mode Management
- Window Operations
- Workspace Management
- Keyboard Input
- Timing and Synchronization
- Best Practices
- Examples
- Running Tape Scripts
- Remote Tape Execution
Lines starting with # are comments and are ignored by the parser:
# This is a comment
NewWindow # Inline comments are not supported
Commands are case-sensitive and follow this general format:
CommandName [arguments...]
Strings can be quoted with double quotes, single quotes, or backticks:
Type "hello world"
Type 'hello world'
Type `hello world`
Escape sequences are supported in double-quoted strings:
Type "Line 1\nLine 2\tTabbed"
Durations support standard Go duration formats:
Sleep 500ms # Milliseconds
Sleep 2s # Seconds
Sleep 1.5s # Decimal seconds
Sleep 1m # Minutes
Sleep 1h # Hours
TUIOS has two primary modes: Window Management Mode (for managing windows) and Terminal Mode (for interacting with terminal content).
Switch to window management mode for window operations.
WindowManagementMode
Switch to terminal mode to send input to the focused window.
TerminalMode
Workflow Pattern:
WindowManagementMode # Navigate/manage windows
NewWindow
TerminalMode # Type into the window
Type "ls -la"
Enter
WindowManagementMode # Back to managing windows
Create a new terminal window in the current workspace.
NewWindow
Sleep 500ms # Wait for window to initialize
Close the currently focused window.
CloseWindow
Focus the next window in the current workspace.
NextWindow
Sleep 200ms
Focus the previous window in the current workspace.
PrevWindow
Sleep 200ms
Focus a specific window by ID (advanced usage).
FocusWindow "window-uuid-here"
Rename the currently focused window.
RenameWindow "My Terminal"
Minimize the currently focused window to the dock.
MinimizeWindow
Sleep 300ms # Wait for animation
Restore a minimized window.
RestoreWindow
Sleep 300ms
Toggle tiling mode on/off for the current workspace.
ToggleTiling
Explicitly enable tiling mode.
EnableTiling
Sleep 300ms
Explicitly disable tiling mode.
DisableTiling
Sleep 300ms
Snap the focused window to the left half of the screen.
SnapLeft
Sleep 200ms
Snap the focused window to the right half of the screen.
SnapRight
Sleep 200ms
Snap the focused window to fullscreen.
SnapFullscreen
Sleep 200ms
TUIOS supports 9 workspaces (numbered 1-9).
Switch to a specific workspace (1-9).
SwitchWorkspace 2
Sleep 400ms
Move the focused window to another workspace (without following it).
MoveToWorkspace 3
Move the focused window to another workspace and switch to it.
MoveAndFollowWorkspace 2
Sleep 400ms
All keyboard input commands require Terminal Mode to be active.
Type a string of text into the focused terminal.
TerminalMode
Type "echo 'Hello, World!'"
Enter # Press Enter
Space # Press Space
Tab # Press Tab
Backspace # Press Backspace
Delete # Press Delete
Escape # Press Escape
Up # Arrow up
Down # Arrow down
Left # Arrow left
Right # Arrow right
Home # Home key
End # End key
Use + to combine modifier keys with regular keys:
Ctrl+c # Control + C
Ctrl+b # TUIOS leader key
Alt+1 # Alt + 1
Shift+Tab # Shift + Tab
Ctrl+Alt+t # Multiple modifiers
Modifiers:
Ctrl- Control keyAlt- Alt/Option keyShift- Shift key
Pause script execution for a specified duration.
Sleep 500ms
Sleep 1s
Sleep 1.5s
Alternative syntax for waiting.
Wait 500ms
Wait until the terminal output matches a regex pattern (with optional timeout in milliseconds).
TerminalMode
Type "ls -la"
Enter
# Wait for command to complete (look for prompt)
WaitUntilRegex "\\$" 3000
Timeout:
- Default: 5000ms (5 seconds)
- Specify custom timeout as second argument
WaitUntilRegex "test" 10000 # 10 second timeout
Give TUIOS time to process animations and state changes:
NewWindow
Sleep 500ms # Wait for window creation
MinimizeWindow
Sleep 300ms # Wait for minimize animation
Always switch modes explicitly before performing mode-specific actions:
# GOOD
WindowManagementMode
NewWindow
TerminalMode
Type "ls"
# BAD (mode might be wrong)
NewWindow
Type "ls"
Document complex workflows:
# Setup development environment
WindowManagementMode
EnableTiling
# Create editor window
NewWindow
TerminalMode
Type "vim main.go"
Enter
Sleep 800ms
# Create build window
WindowManagementMode
NewWindow
TerminalMode
Type "go build -watch"
Enter
Use workspaces to group related windows:
# Workspace 1: Development
SwitchWorkspace 1
NewWindow # Editor
NewWindow # Terminal
# Workspace 2: Monitoring
SwitchWorkspace 2
NewWindow # Logs
NewWindow # System stats
# Workspace 3: Documentation
SwitchWorkspace 3
NewWindow # Browser/docs
Use longer timeouts for potentially slow operations:
TerminalMode
Type "npm install"
Enter
WaitUntilRegex "completed" 60000 # 60 second timeout for npm
Use consistent sleep durations for similar actions:
# Window creation: 500ms
NewWindow
Sleep 500ms
# Window navigation: 200ms
NextWindow
Sleep 200ms
# Animations: 300ms
MinimizeWindow
Sleep 300ms
# Create a simple dev environment
WindowManagementMode
EnableTiling
Sleep 300ms
# Editor window
NewWindow
Sleep 500ms
TerminalMode
Type "vim README.md"
Enter
Sleep 800ms
# Terminal window
WindowManagementMode
NewWindow
Sleep 500ms
TerminalMode
Type "ls -la"
Enter
# Setup project workspaces
WindowManagementMode
# Workspace 1: Coding
SwitchWorkspace 1
EnableTiling
NewWindow
TerminalMode
Type "vim main.go"
Enter
Sleep 500ms
WindowManagementMode
NewWindow
TerminalMode
Type "go run ."
Enter
# Workspace 2: Testing
WindowManagementMode
SwitchWorkspace 2
NewWindow
TerminalMode
Type "go test -v ./..."
Enter
# Workspace 3: Git
WindowManagementMode
SwitchWorkspace 3
NewWindow
TerminalMode
Type "git status"
Enter
# Return to main workspace
WindowManagementMode
SwitchWorkspace 1
WindowManagementMode
NewWindow
Sleep 500ms
TerminalMode
# Start a long-running build
Type "make build"
Enter
# Wait for build completion
WaitUntilRegex "Build complete" 120000
# Run the result
Type "./output"
Enter
WindowManagementMode
DisableTiling # Use manual positioning
# Left half
NewWindow
Sleep 300ms
SnapLeft
Sleep 200ms
# Right half top
NewWindow
Sleep 300ms
SnapRight
Sleep 200ms
# Fullscreen overlay
NewWindow
Sleep 300ms
SnapFullscreen
Sleep 200ms
# Minimize to see others
MinimizeWindow
Sleep 300ms
The following features are planned for future releases:
Set windowName "My Terminal"
RenameWindow $windowName
Repeat 5 {
NewWindow
Sleep 200ms
}
If WindowCount > 5 {
MinimizeWindow
}
Define CreateDevWindow {
NewWindow
TerminalMode
Type "vim"
Enter
}
Call CreateDevWindow
Output "screenshot.png"
Type "neofetch"
Enter
Sleep 2s
- Check mode: Ensure you're in the correct mode (Window Management vs Terminal)
- Add delays: Increase
Sleepdurations if actions are happening too fast - Validate syntax: Run
tuios tape validate script.tapeto check for errors - Check regex: Test regex patterns separately before using in
WaitUntilRegex
"Unknown command": Check spelling and capitalization (commands are case-sensitive)
"Unexpected token": Check for missing quotes around strings
"Timeout waiting for pattern": Increase timeout or verify regex pattern matches expected output
Run without showing the TUI (for CI/CD):
tuios tape run script.tapeWatch the script execute in real-time:
tuios tape play script.tapeCheck syntax without running:
tuios tape validate script.tapeCreate scripts from live interactions (coming soon):
tuios tape record output.tapeThe tuios tape exec command allows you to run tape scripts against an already running TUIOS session. This enables automation workflows where TUIOS is running in daemon mode or in another terminal.
# Execute a tape script against the current session
tuios tape exec script.tape
# Execute against a specific session
tuios tape exec --session mysession script.tape
tuios tape exec -s mysession script.tapeRemote execution shows a progress indicator during script execution:
Executing script.tape...
Progress: 5/12 [███████░░░░░░░░░░░░░] 41%
Automation pipelines:
# Start a session in the background
tuios new automation &
sleep 2
# Execute setup script
tuios tape exec -s automation setup.tape
# Run tests
tuios tape exec -s automation test-workflow.tape
# Cleanup
tuios kill-session automationDevelopment workflows:
# In terminal 1: Start TUIOS
tuios new dev
# In terminal 2: Send scripts to configure environment
tuios tape exec -s dev environment-setup.tapeIntegration testing:
#!/bin/bash
# Run multiple scripts and check results
tuios tape exec test-suite-1.tape
tuios tape exec test-suite-2.tape
# Query state after tests
WINDOWS=$(tuios list-windows --json | jq '.total')
echo "Test created $WINDOWS windows"Remote tape execution works seamlessly with other CLI commands:
# Execute script then query state
tuios tape exec setup.tape
tuios session-info --json | jq '.total_windows'
# Execute script and capture window ID
tuios tape exec create-window.tape
WINDOW_ID=$(tuios get-window --json | jq -r '.id')
echo "Created window: $WINDOW_ID"| Feature | tape play |
tape exec |
|---|---|---|
| Starts TUIOS | Yes | No (requires running session) |
| Shows TUI | Yes | No (progress bar only) |
| Interactive | Yes | No |
| For automation | No | Yes |
| Session persistence | No | Yes (works with daemon) |
Tape files use the .tape extension and are plain text files with UTF-8 encoding.
Recommended structure:
# Header comment describing the script
# Author: Your Name
# Purpose: What this script does
# Version: 1.0
# Main script body
WindowManagementMode
# ... commands ...
# Footer
Sleep 1s
# End of script
- TUIOS Keybindings Documentation
- TUIOS Configuration Guide
- Example Tape Scripts
- AGENTS.md - Development guide
Last Updated: 2025-11-27
TUIOS Version: 0.4.0+