9term 1.2 recoverably tiles every Apple Terminal window inside the left 50%
of the leftmost display. It selects a compact grid for the current window
count, refuses cells that are too small to remain usable, resizes every window
to an equal grid cell, and lets Terminal calculate rows and columns for each
window's font.
It uses stable Terminal window IDs, Terminal's native Apple Events interface,
and AppKit display geometry. Every Apple Event is checked immediately. Before
mutation it saves a private geometry-only snapshot; failures roll back and a
successful run can be reverted with 9term undo.
make
make test
make analyze
make installThe default installation path is ~/.local/bin/9term.
Adaptively arrange all Apple Terminal windows in the left half:
9termUse the original exact 80-column by 30-row layout:
9term fixedInspect the current displays and windows without moving anything:
9term statusPreview the adaptive layout without moving anything:
9term dry-runRestore the exact geometry, cells, minimized/zoom state, and visibility saved before the most recent successful arrangement:
9term undoTerminal may round a restored grid by one row or column while accepting the saved pixel bounds; that near-exact result is accepted instead of being reverted back to the tiled state.
If an unfinished snapshot is corrupt or otherwise unusable, remove only that pending transaction with:
9term discard-pendingThe discard command removes a file, symlink, or empty directory only. It refuses a foreign-owned or non-empty directory and tells you which documented cache path to inspect manually instead of deleting recursively.
Adaptive windows are ordered by the stable ID references returned for Terminal's current front-to-back list. The grid uses the left half of the leftmost display's usable area, keeps Terminal-shaped cells, minimizes unused slots, and uses a 10-point gap.
Minimized windows are restored for arrangement. Existing tabs, shells, profiles, fonts, contents, and working directories are not read or changed. To keep failure recovery bounded, a single run refuses more than 256 windows.
The undo snapshot contains only window IDs, bounds, row/column counts,
visibility, minimized/zoom state, and the Terminal process ID needed to reject
stale snapshots after Terminal restarts. The process launch time is stored too,
so a later reuse of the same PID is rejected. The snapshot is stored with mode 0600 under
~/Library/Caches/9term/last-layout.json, overwritten by the next successful
run, and deleted after a successful undo.
An in-progress arrangement uses a separate private
pending-layout.json. A normal failure removes it only after rollback
completes; a crash leaves it for 9term undo. A new arrangement refuses to
overwrite an unfinished transaction, and an older successful undo point is not
discarded unless the new arrangement completes. A private per-user lock
serializes layout, undo, and pending-discard transactions. If Terminal restarts,
its old window IDs are unsafe to reuse; 9term undo discards that provably
stale pending transaction and asks you to run the intended command again.
Undoing a pending transaction preserves the previous successful-layout
snapshot and clearly reports that a second undo would intentionally restore
that older state.
On first use, macOS may ask whether your terminal may control Apple Terminal. Allow it. If control was previously denied, open:
System Settings > Privacy & Security > Automation
and enable Apple Terminal for the terminal app from which you run 9term.
- macOS
- Apple Terminal
- Xcode Command Line Tools for source builds only
Version 1.2 controls Apple Terminal. Other terminal applications expose different sizing interfaces and are intentionally not approximated as pixel-only windows.
Terminal may expose scriptable windows from multiple Spaces. 9term attempts to
arrange all returned windows. Native full-screen windows can reject geometry
changes; if any operation fails or Terminal does not accept the requested
frame, 9term rolls back every window it already changed. A forced process kill
cannot execute in-process rollback, so run 9term undo afterward. Recovery can
restore windows only while they still belong to the same Terminal process; a
Terminal restart invalidates those stable IDs and the stale pending snapshot is
discarded rather than applied to unrelated windows.
Fixed mode first resizes windows to 80x30, calculates whether all resulting windows fit, and rolls everything back instead of placing any window off-screen when they do not.
This is a source-only project. Published prebuilt binaries would require Developer ID signing, hardened runtime, notarization, and checksums; none are claimed by this repository.