BoxMux turns a YAML file into a terminal interface. You describe boxes, their positions and what goes in them: text, the output of shell scripts (run once or on an interval), menus whose entries run scripts, interactive programs in an embedded terminal, charts, tables, or content drawn by a plugin. BoxMux draws the boxes, runs the scripts, and handles the keyboard and the mouse. A running instance can be controlled from other programs through a local socket.
You need a stable Rust toolchain (rustup).
cargo install boxmuxgit clone https://github.com/jowharshamshiri/boxmux.git
cd boxmux
cargo build --release
./target/release/boxmux layouts/showcase_menu.yamlThe layouts/ and examples/ directories hold ready-made configurations to try.
Releases are built with scripts/release.sh, which runs the mg-test release plan
(mg-test/release.yaml). A GitHub release made this way carries:
boxmux-<version>-linux-x86_64.tar.gzandboxmux-<version>-linux-aarch64.tar.gz.deband.rpmpackages for Linux x86-64 and arm64boxmux-<version>-windows-x86_64.zipSHA256SUMS
Save this as hello.yaml:
app:
layouts:
- id: main
root: true
title: Hello BoxMux
children:
- id: welcome
title: Welcome
position: {x1: 0%, y1: 0%, x2: 50%, y2: 100%}
content: |
Hello from BoxMux.
Tab moves the focus, Enter runs a menu entry, q quits.
- id: clock
title: Clock
position: {x1: 50%, y1: 0%, x2: 100%, y2: 40%}
refresh_interval: 1000
script:
- date
- id: actions
title: Actions
position: {x1: 50%, y1: 40%, x2: 100%, y2: 100%}
tab_order: 1
choices:
- id: disk
content: Disk usage
script:
- df -h
- id: who
content: Who am I
script:
- whoamiRun it:
boxmux hello.yamlThe clock box reruns date every second. Selecting a menu entry runs its script and shows the
output in a new tab of the Actions box. Positions are percentages of the parent (here the
screen) or cell counts written as strings ("12"). Unknown keys and invalid values are load
errors that name the place in the file.
Usage: boxmux [OPTIONS] <config>
boxmux [--socket <NAME>] <COMMAND> [ARGS]
Commands:
replace_box_content Show text in a box's socket tab
replace_box_script Replace a box's script and run it
stop_box_refresh Pause a box's periodic refresh
start_box_refresh Resume a box's periodic refresh
replace_box Replace a box with the one described in JSON
add_box Add a box, described in JSON, to a layout
remove_box Remove a box
switch_active_layout Show another layout
spawn_pty_process Run a script in a terminal shown in a box
kill_pty_process Stop the process in a box's visible tab
restart_pty_process Restart the process in a box's visible tab
query_pty_status Report on the process in a box's visible tab
send_pty_input Type input into the terminal in a box's visible tab
send_signal Send a signal to the process in a box's visible tab
help Print this message or the help of the given subcommand(s)
Arguments:
<config> The YAML file describing the interface
Options:
-d, --frame-delay <MS> Minimum time between two redraws, in milliseconds [default: 30]
--log-file <FILE> Write a log to FILE
--log-level <LEVEL> How much to log [default: info] [possible values: error, warn, info, debug, trace]
--lock Disable moving and resizing boxes; the YAML file is never written
--calibrate Highlight the cell under the mouse pointer
--dark Use the dark color theme regardless of the terminal
--light Use the light color theme regardless of the terminal
--socket <NAME> The control socket (default: $BOXMUX_SOCKET, or a per-user default)
-h, --help Print help
-V, --version Print version
boxmux <command> --helpshows the arguments of each control command.--log-levelneeds--log-file.--darkand--lightcannot be combined.- The interface options cannot be combined with a control command.
- Moving or resizing a box with the mouse writes the new position back into the YAML file,
keeping comments and units.
--lockturns this off. Without--lock, BoxMux holds a lock file (<config>.lock) so that a second instance cannot edit the same file.
A running BoxMux listens on a control socket: $XDG_RUNTIME_DIR/boxmux.sock (or
/tmp/boxmux-<uid>.sock) on Unix, the named pipe boxmux-<USERNAME> on Windows, unless
--socket or $BOXMUX_SOCKET names another. From another terminal:
boxmux replace_box_content welcome "Deployment finished"
boxmux stop_box_refresh clock
boxmux switch_active_layout mainScripts started by BoxMux get BOXMUX_SOCKET and BOXMUX_BOX (the id of the box they run for)
in their environment, so they can control the instance they run in. The protocol is one JSON
line per request; see the API reference.
- Layouts and boxes: several layouts per file (one shown at a time, switchable over the
socket), nested boxes positioned in percentages or cells,
anchorwith minimum and maximum sizes,z_indexfor overlapping boxes. - Scripts: run once or every
refresh_intervalmilliseconds; three execution modes:Immediate(output shown when the script ends),Thread(output streamed line by line) andPty(an interactive terminal in the box). Output can go to another box (redirect_output), be appended (append_output), follow the newest line (auto_scroll_bottom) and be saved to a file (save_in_file). Shared shell functions can be sourced fromlibs. - Menus:
choicesrun their scripts with Enter or a click; each run opens its own tab.hot_keysbind keys to choices, andon_keypressbinds keys to scripts at app, layout or box level. - Tabs: a box with several outputs (its content, its script output, menu runs, socket updates) shows them as tabs in its top border; extra tabs can be closed.
- Embedded terminal:
execution_mode: Ptyruns programs such ashtop,vimor a shell in the box, with 256 and 24-bit color, the alternate screen, mouse reporting and scrollback. - Charts and tables: bar, line, histogram, pie and scatter charts; tables from CSV or JSON with sorting, filtering and paging. Data can be inline or come from a script.
- Plugins: shared libraries with a small C interface can draw box content.
- Variables:
${NAME}and${NAME:default}with values from boxes, layouts, the app or the environment. - Mouse: click to focus, run menu entries and switch tabs; drag the top border to move a box and the bottom-right corner to resize it; scrollbars and the wheel scroll.
- Keyboard: Tab and Shift+Tab move the focus along
tab_order(ornext_focus_id), arrows and Page Up/Down scroll, Ctrl+C copies the focused box's visible text to the clipboard (through the terminal, with OSC 52). - Colors: 16 ANSI color names for borders, text, titles and menus, with separate colors for
the focused box, the box under the pointer and failed runs. The light or dark default theme
follows the terminal background, or is set with
--light/--dark.
- Linux (x86-64 and arm64) and FreeBSD: tested.
- macOS: uses the same Unix code, but is not tested on macOS machines.
- Windows 10 and later: terminals use ConPTY; scripts run in PowerShell unless
app.shellsays otherwise;send_signalis not supported; the terminal background is not queried, so the theme comes fromCOLORFGBG,--light/--dark, or defaults to dark.
On Unix, scripts run in bash unless app.shell is sh or zsh (powershell and pwsh are
also accepted).
The documentation is at boxmux.com; its source is in
docs/src/content/.
- User Guide: building an interface step by step
- Configuration Reference: every YAML setting
- Examples
- API Reference: the control socket and commands
- PTY Features: interactive programs in boxes
- Data Visualization: charts and tables
- Plugin System: writing plugins
- Variables
- Advanced Features
- Troubleshooting
cargo build
cargo test # unit tests, runtime tests and end-to-end tests
cargo test --test live_ux # only the end-to-end tests (the real binary in a pseudo-terminal)
cargo clippy --all-targets -- -D warnings
cargo fmt --checkCross-platform runs use mg-test, which starts virtual machines, copies the
tracked files into them and runs the plans in mg-test/:
| Plan | Machines | What runs |
|---|---|---|
hosts |
Ubuntu x86-64, Windows 11 x86-64 | formatting (Linux only), clippy and all tests |
arm64 |
Ubuntu arm64 | formatting, clippy and all tests |
freebsd |
FreeBSD x86-64 | formatting, clippy and all tests |
release |
Ubuntu x86-64 and arm64, Windows 11 x86-64 | release builds and packages |
mg-test run mg-test.yaml --plan hostsThe runners are mg-test/test.sh (Linux and FreeBSD) and mg-test/test.ps1 (Windows). See
CONTRIBUTING.md for the project layout and conventions, and
CHANGELOG.md for the history.
MIT. See LICENSE.