Runnable programs
Complete programs that start a private tmux server, do one job and close it.
Run them from the repository root after the
toolchain setup, with tmux on PATH:
$ zef install .| Task | Program | Raku facilities |
|---|---|---|
| Create and find panes¶ | Quickstart | Objects, LEAVE, a native predicate |
| Resize and remove panes¶ | Resize panes | resize, kill, fresh snapshots |
| Select wide panes¶ | Pane queries | Typed selections, query hashes, grep, map, sort |
| Choose where a query runs¶ | Query plan | explain-panes, :pushdown |
| Add a status pane¶ | Floating panes | Capability checks and a tiled fallback |
| Watch pane output¶ | Watch output | Promise, Supply, react, whenever |
| Combine the workflow¶ | Session workflow | Events, captured graphs and query plans |
| Recover after a command fails¶ | Batch recovery | Typed outcomes and explicit recovery |
Create and find panes¶
quickstart.raku splits one pane, titles both and finds
editor in a fresh snapshot. The earlier snapshot still has one pane.
$ raku -I. examples/quickstart.rakuIt prints editor: 2 panes.
Resize and remove panes¶
resize-panes.raku splits a pane, resizes the window and
the first pane, then kills the second pane. A fresh snapshot reads each result.
$ raku -I. examples/resize-panes.rakuIt prints window: 100x20, editor: 30 columns and panes: 1.
Select wide panes¶
query-panes.raku creates editor, tests and logs.
.where selects wide panes, .filter finds editor, .single checks the
count, and .grep, .map and .sort list the rest.
$ raku -I. examples/query-panes.rakuIt prints Wide pane: editor and Other panes: logs, tests.
- Bind a typed selection with
:=;=copies it into a plain array. - Repeated traversal reads the captured members and does not refresh tmux.
Choose where a query runs¶
explain-query.raku explains two pane queries, runs one,
and shows :pushdown<require> refusing the query that keeps a title test local.
$ raku -I. examples/explain-query.rakuIt prints whether each query is fully pushed to tmux, the filter tmux gets, the match, and the refusal.
Add a status pane¶
floating-panes.raku creates an empty status pane:
floating when the daemon reports pane-floating, tiled otherwise.
$ raku -I. examples/floating-panes.rakuIt prints Status pane: floating or Status pane: tiled, then status.
Watch pane output¶
watch-output.raku subscribes to pane-output events, sends
text to cat and collects the echoed bytes with react and whenever. Then it
checks the captured screen.
$ raku -I. examples/watch-output.rakuIt prints hello from Raku and Screen capture confirmed.
- A deadline bounds the wait.
- Several subscribers can share one connection.
- Sending text and pressing Enter are separate calls.
Run the complete session workflow¶
session-workflow.raku creates panes, sends input,
watches control-mode output and captures the screen. It filters a snapshot,
then compares an exact source query with the captured pane.
$ raku -I. examples/session-workflow.rakuThe output includes Session: 2 panes, editor: hello from Raku and
Owned clients, daemon and socket cleaned up.
Recover after a command fails¶
batch-recovery.raku sets an option, sends an invalid
command and checks that the next command was skipped. It then removes the
first effect.
$ raku -I. examples/batch-recovery.rakuIt prints the Complete, Failed and Skipped outcomes, then
Recovery: removed the first effect explicitly and
Owned daemon and socket cleaned up.
A failed batch does not undo commands that already succeeded.
Select a tmux executable¶
Every program except the quickstart takes --tmux=PATH. The quickstart runs
tmux from PATH.
The example check runs every program against
LIBTMUX_TEST_TMUX, compares its output and rejects leftover sockets. See
Contributing.