Appearance
AppleScript Automation
Otty is scriptable with AppleScript, so you can drive it from osascript, Automator, Shortcuts (via Run AppleScript), or any automation that already talks to a terminal. The dictionary is intentionally drop-in compatible with Terminal.app's most common verbs — most scripts written for Apple's Terminal work by changing the application name to "Otty".
There's nothing to install or enable: scripting ships in the app.
Availability
AppleScript support requires Otty 1.2.0 or later.
Running a command — do script
The core verb is do script. With no target it opens a new window and runs the command there, exactly like Terminal.app:
applescript
tell application "Otty"
activate
do script "cd ~/Projects/otty && cargo build"
end tellRun in an existing window or tab by passing in:
applescript
tell application "Otty"
do script "git status" in front window -- the window's selected tab
do script "npm test" in tab 2 of window 1
end telldo script returns the tab it ran in, so you can keep a handle to it:
applescript
tell application "Otty"
set buildTab to do script "make release"
set custom title of buildTab to "Release Build"
end tellReading what's on screen
Each tab exposes its state as properties:
| Property | Meaning |
|---|---|
contents | The text currently visible on screen |
history | The full scrollback plus the visible screen |
busy | true while a foreground process (not the shell) is running |
processes | Names of the processes running in the tab |
tty | The tty device path, e.g. /dev/ttys003 |
number of rows / number of columns | The grid size |
working directory | The shell's current directory |
id | The session id (also a selector for the otty CLI) |
applescript
tell application "Otty"
set t to do script "ls -la"
delay 0.5
return contents of t -- grab the visible output
end tellA common pattern — run a command, wait for it to finish, then read the result:
applescript
tell application "Otty"
set t to do script "sleep 2; echo done"
repeat while busy of t
delay 0.2
end repeat
return history of t
end tellTitles, selection, and windows
applescript
tell application "Otty"
-- Rename a tab (pins the title against shell updates).
set custom title of selected tab of front window to "Deploy"
-- Restore the shell-provided title.
set custom title of selected tab of front window to ""
-- Bring a background tab forward.
set selected of tab 3 of window 1 to true
-- Standard window verbs work too.
count windows
get name of front window
end tellMigrating from Terminal.app
Most Terminal scripts need only the application name changed:
applescript
-- Before
tell application "Terminal" to do script "uptime"
-- After
tell application "Otty" to do script "uptime"The do script semantics, the tab object with contents / history / busy / processes / tty / custom title, and selected tab of a window all match Terminal.app's behavior.
Security
do script is allowed by default — automation should just work. To keep scripts from silently reading or driving sensitive panes, two guards apply:
- SSH sessions and privileged (sudo) sessions are protected.
do scriptinto them is refused, andcontents/historyreturn empty.
This mirrors the same protection used by the otty CLI (pane send-keys / pane capture). If you intentionally want automation to reach remote or privileged panes, set in your config:
ipc-allow-sensitive-sessions = truePrefer the shell?
If you script from a shell rather than AppleScript, the otty CLI covers the same ground — otty open, otty tab new, otty pane send-keys, and otty pane capture — and works cross-platform.