Scripting sessions
Alto’s commands do from a script or an agent what tmux’s do, against real sessions you can also see in the window.
id=$(alto new -- npm run dev) # start one; prints its idalto wait "$id" --text 'ready on port \d+' --timeout 60alto capture "$id" --last 20 # the last lines, as plain textalto send "$id" --key C-c # press keysalto kill "$id"Waiting
Section titled “Waiting”alto wait 3 --until needs-you # idle, working, needs-you, done, or promptalto wait 3 --text 'error|panic' --timeout 2mExits 0 when it happens (printing what it found), 124 after --timeout, 125 if the session ends. --text is a regular expression over what the program prints from now on; for what’s already on screen, use capture --screen.
Running a command and getting its result
Section titled “Running a command and getting its result”alto run 3 -- cargo test # prints only its output, exits with its statusalto run 3 --json -- make lint # {output, exit, truncated, took, timed_out}run types the command at the session’s prompt, where it shows, and waits for it by the shell’s own marks. See What run gives back.
Typing
Section titled “Typing”alto send 3 'git status' --enteralto send 3 --key Escape # leave insert modealto send 3 ':wq' --enterKeys go by name: Enter, Escape, Tab, Up, PageDown, F5, q, with C-, M- or S- before them (C-c, M-x, S-Tab). Repeat --key for several, pressed in order.
On another computer
Section titled “On another computer”--on DEVICE works with ls, new, attach, send, capture and kill, and with run and wait:
alto --on studio new -- ./train.shalto --on studio capture 4 --last 50See Remote access with Tailscale.
A separate set of sessions
Section titled “A separate set of sessions”ALTO_HOME=/some/folder keeps a separate server, sessions and settings in that folder, for trying things without touching your own:
export ALTO_HOME=$(mktemp -d)alto new -- sleep 600alto ls