Automate

On a server

The bateri command on a server over ssh, the panes of another machine, and what each machine may do.

In a terminal on a server, opened in bateri over ssh, the bateri command is on the PATH too and works the same way. The terminal itself lives on the server, under kablo, so a program there can open panes and talk to them with your Mac asleep; a pane takes its place in your window when bateri connects.

The panes of another machine

A pane of another machine is written with the machine after an @, as bateri ls writes it: p9@prod, and p3@local for this Mac.

bateri split -S prod -- make test   # a terminal on the server prod; prints p9@prod
bateri send p9@prod 'q'             # capture, send-key and wait reach it the same way
bateri focus pane p9@prod

focus, close, zoom, swap, move and resize take such an address from level screen up. -S and send, send-key, capture and wait for p9@prod are for level full alone, on the machine the command runs on, and the server’s own commands must not be off.

-S SERVER starts the terminal on a server instead of here, by the name you give ssh (a host, or an alias of ~/.ssh/config), through the same gate as ssh prod in a bateri pane. bateri asks for a password in its usual sheet when the connection must be made, installs nothing on the server (open a terminal on it in bateri first), and the pane opens at once and connects by its own path. send, send-key, capture and wait for p9@prod run there over the connection bateri keeps.

What a machine may do

Each machine has a level, and nobody is asked. The same four words hold for this Mac and for a server:

Level Sees Changes and closes On another machine
off The command does not exist on that machine Nothing Nothing
own The panes of that machine, and the windows, groups and tabs that hold one Its own panes; a tab, group or window only when every pane in it is its own Nothing
screen Everything bateri has open, each pane named with its machine (p9@prod) Everything Nothing
full As screen As screen Starts terminals, types into them and reads them

own is the default. It is a guard against accidents, not a security boundary. A command the level refuses ends with status 77 and one line that names the level and the setting.

This Mac’s level is level in the [commands] section of your settings, or Programs on this computer may in Settings ▸ Shell. A server’s level is the commands key of its entry in [remote] hosts, by its exact name:

# ~/.config/bateri/settings.toml
[commands]
level = "own"      # "off", "own", "screen" or "full"

[remote]
hosts = [
  { host = "rasp", commands = "full" },
]

full on a server is a risk. If that server is ever taken over, whoever holds it can run commands on this Mac through the window. Give it to a host by its exact name: a pattern such as prod-* is read as own.

From a server

A server you gave full can do the same to your other machines:

bateri split -S rasp -- make test
bateri send p9@rasp 'q'
bateri capture p3@local
bateri split -S @local -- make test   # a terminal on this Mac

It has no connection to them, so bateri runs the command for it: the bateri of the other machine, from its full path in a login shell, and hands back what it printed and how it ended. That is the one thing bateri runs for a program, which is why the level is spelled out: a server that is taken over can then do on your other machines what you can.

split, send, send-key, capture, wait and close are all it relays; a server at own or screen gets the same refusal as anywhere else. A split with no program on this Mac needs a pane to go beside, which a relayed command is not in: name a program.