PTY shell

Open

let shell = try await connection.openShell(
    terminalType: "xterm-256color",
    columns: 120,
    rows: 32
) { event in
    if case .standardOutput(let data) = event {
        FileHandle.standardOutput.write(data)
    }
}

try await shell.write("ls -la\n")
try await shell.write(Data([0x03]))   // Ctrl-C
try await shell.close()

The event handler runs off the worker queue; do your own dispatch if you need to mutate UI state.

Resize

try await shell.resize(columns: 200, rows: 50)

Resizing emits SIGWINCH on the remote PTY. Resize early and often if you have a terminal view that the user can drag.

Events

SSHShellEvent has three cases:

PTY modes

openShell requests a PTY from the remote with a fixed, conservative mode set. The current public API exposes the terminal type and dimensions; the line discipline itself is not configurable. SSHKit picks values that match what an interactive OpenSSH client would request, so you get the same behavior most users (and most remote shells) already expect.

What is on

Implications