Tape Scripting
Automate TUIOS workflows with tape files
Tape Scripting
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.
Perfect for...
- Recording and replaying terminal workflows
- Automated testing
- Demo recording
- CI/CD automation
- Documenting workflows
Running Tape Scripts
# Interactive mode (visible TUI) - watch automation happen
tuios tape play demo.tape
# Validate syntax
tuios tape validate demo.tape
# List saved recordings
tuios tape list
# Show a tape file
tuios tape show my-recordingRemote Execution
The tuios tape exec command allows you to run tape scripts against an already running TUIOS session. This is perfect for automation workflows where TUIOS is running in daemon mode.
# Execute against current session
tuios tape exec script.tape
# Execute against a specific session
tuios tape exec -s mysession script.tapeProgress Display
Remote execution shows a progress indicator:
Executing script.tape... Progress: 5/12 [███████░░░░░░░░░░░░░] 41%
Use Cases
Automation pipelines:
#!/bin/bash
# Start a session
tuios new automation &
sleep 2
# Execute scripts
tuios tape exec -s automation setup.tape
tuios tape exec -s automation test-workflow.tape
# Cleanup
tuios kill-session automationDevelopment workflows:
# Terminal 1: Start TUIOS
tuios new dev
# Terminal 2: Send scripts
tuios tape exec -s dev environment-setup.tapeDifferences from tape play
| 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) |
Combining with CLI Commands
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'
# Create window via command, then run tape
tuios run-command NewWindow "dev"
tuios tape exec dev-setup.tapeSee Sessions & Remote Control for more about controlling TUIOS from external scripts.
Basic Syntax
Comments
Lines starting with # are comments:
# This is a comment
NewWindow # Create a windowCommands
Commands are case-sensitive:
NewWindow
Sleep 500ms
TerminalMode
Type "echo hello"
EnterString Literals
Type "hello world"
Type 'hello world'
Type `hello world`Durations
Sleep 500ms # Milliseconds
Sleep 2s # Seconds
Sleep 1.5s # Decimal secondsMode Management
Important
TUIOS has two modes: Window Management Mode and Terminal Mode. Always switch modes explicitly before mode-specific commands!
WindowManagementMode
Switch to window management mode for managing windows.
WindowManagementModeTerminalMode
Switch to terminal mode to send input to the focused window.
TerminalModeExample workflow:
WindowManagementMode
NewWindow
TerminalMode
Type "ls -la"
Enter
WindowManagementModeWindow Operations
NewWindow
Create a new terminal window.
NewWindow
Sleep 500ms # Give time for creationCloseWindow
Close the currently focused window.
CloseWindowNextWindow / PrevWindow
Navigate between windows.
NextWindow
Sleep 200msRenameWindow
Rename the focused window.
RenameWindow "My Terminal"MinimizeWindow / RestoreWindow
Minimize and restore windows.
MinimizeWindow
Sleep 300ms
RestoreWindowTiling and Layout
ToggleTiling
Toggle tiling mode.
ToggleTilingEnableTiling / DisableTiling
Explicitly control tiling mode.
EnableTiling
Sleep 300msAnimation Control
EnableAnimations / DisableAnimations / ToggleAnimations
Control window animations during tape playback.
DisableAnimations # Instant transitions
NewWindow
EnableAnimations # Restore animationsRecorded Tapes
When you record a tape, TUIOS automatically prepends DisableAnimations at the start and appends EnableAnimations at the end. This ensures tape playback is reproducible regardless of the user's animation settings.
Animation Sync
Tape playback automatically waits for animations to complete before executing the next command. This ensures smooth, synchronized execution even with animations enabled.
Snap Commands
Snap windows to positions.
SnapLeft
SnapRight
SnapFullscreenWorkspace Management
TUIOS supports 9 workspaces (1-9).
SwitchWorkspace
Switch to a workspace.
SwitchWorkspace 2
Sleep 400msMoveToWorkspace
Move window to workspace.
MoveToWorkspace 3MoveAndFollowWorkspace
Move and follow.
MoveAndFollowWorkspace 2Keyboard Input
Terminal Mode Required
Keyboard commands only work in Terminal Mode!
Type
Type text into terminal.
TerminalMode
Type "echo 'Hello, World!'"Basic Keys
Enter
Space
Tab
Backspace
Delete
EscapeNavigation Keys
Up
Down
Left
Right
Home
EndKey Combinations
Ctrl+c
Ctrl+b
Alt+1
Shift+Tab
Ctrl+Alt+tTiming
Sleep
Pause execution.
Sleep 500ms
Sleep 1sWaitUntilRegex
Wait for terminal output to match a pattern.
TerminalMode
Type "ls -la"
Enter
WaitUntilRegex "\$" 3000 # Wait for promptExample Scripts
Basic Workflow
# Create a new window and run commands
WindowManagementMode
NewWindow
Sleep 500ms
TerminalMode
Type "ls -la"
Enter
Sleep 1s
Type "echo 'Done'"
EnterMulti-Workspace Setup
# Setup workspace 1 - development
WindowManagementMode
NewWindow
Sleep 500ms
TerminalMode
Type "cd ~/project"
Enter
# Switch to workspace 2 - monitoring
WindowManagementMode
SwitchWorkspace 2
Sleep 400ms
NewWindow
Sleep 500ms
TerminalMode
Type "htop"
EnterTiling Demo
# Create tiled layout
WindowManagementMode
EnableTiling
NewWindow
Sleep 500ms
NewWindow
Sleep 500ms
NewWindow
Sleep 500ms
# Navigate and type in each
TerminalMode
Type "echo 'Window 1'"
Enter
WindowManagementMode
NextWindow
TerminalMode
Type "echo 'Window 2'"
EnterDevelopment Environment Setup
# Create development workspace
WindowManagementMode
EnableTiling# Window 1: Editor
NewWindow
Sleep 500ms
TerminalMode
Type "nvim ."
Enter# Window 2: Server
WindowManagementMode
NewWindow
Sleep 500ms
TerminalMode
Type "npm run dev"
Enter# Window 3: Tests
WindowManagementMode
NewWindow
Sleep 500ms
TerminalMode
Type "npm test -- --watch"
Enter# Window 4: Git
WindowManagementMode
NewWindow
Sleep 500ms
TerminalMode
Type "git status"
EnterRecording Tapes
You can record your interactions:
Press Ctrl+B T r to start recording
Perform your workflow normally
Press Ctrl+B T s to stop recording
Tape is saved to ~/.local/share/tuios/tapes/
View your recordings:
tuios tape list
tuios tape show my-recordingBest Practices
Always Add Delays
Give TUIOS time to process animations and state changes
NewWindow
Sleep 500ms # Wait for creation (GOOD)
NewWindow
# No sleep - next command might execute too soon (BAD)Explicit Mode Switching
Always switch modes explicitly before mode-specific actions
# GOOD
WindowManagementMode
NewWindow
TerminalMode
Type "ls"
# BAD (mode might be wrong)
NewWindow
Type "ls"Use Comments
Document complex workflows
# Setup development environment
WindowManagementMode
EnableTiling
# Create editor window
NewWindow
Sleep 500ms
# Create terminal window
NewWindow
Sleep 500ms