@mu-crew/muster 0.0.0-stage → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +228 -0
- package/LICENSE +21 -0
- package/README.md +104 -2
- package/bin/muster +3553 -0
- package/docs/agents.md +100 -0
- package/docs/config.md +37 -0
- package/docs/development.md +39 -0
- package/docs/keys-and-views.md +66 -0
- package/docs/rex.md +72 -0
- package/docs/sessions.md +52 -0
- package/examples/config.toml +23 -0
- package/muster.tmux +74 -0
- package/package.json +36 -4
package/docs/agents.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Agents (murmur integration)
|
|
2
|
+
|
|
3
|
+
On **vtmux >= 3.8-rc3** (`vtmux-program-status on`), each session row shows its
|
|
4
|
+
coding agents' state natively via `#{session_program_state}` even without
|
|
5
|
+
murmur. Adding [murmur](https://github.com/mu-crew/murmur) adds per-state
|
|
6
|
+
breakdowns, `crashed` / `waiting`, remote peers, and `prefix a`.
|
|
7
|
+
|
|
8
|
+
## Vanilla tmux 3.8
|
|
9
|
+
|
|
10
|
+
Stock tmux 3.8 drops OSC 7501 and OSC 7577 and has no `#{*_program_state}`
|
|
11
|
+
formats. There the picker, zoxide, root-dir, kill and last-session work, native
|
|
12
|
+
session state is blank (a session only shows state if a remote murmur snapshot
|
|
13
|
+
attaches through it), and untagged local panes do not show in `prefix a`
|
|
14
|
+
(remote peers on vtmux or Rex still appear; jump works to remote tmux/vtmux
|
|
15
|
+
panes). murmur 2.x (branch `release/2.x`) is the clean out; otherwise use
|
|
16
|
+
vtmux >= 3.8-rc3 with `set -s vtmux-program-status on`.
|
|
17
|
+
|
|
18
|
+
## Agent state
|
|
19
|
+
|
|
20
|
+
On vtmux >= 3.8-rc3 (`vtmux-program-status on`), muster reads the native
|
|
21
|
+
`#{session_program_state}` per session (and `#{window_program_state}` for the
|
|
22
|
+
preview), in a single
|
|
23
|
+
`list-sessions` call. vtmux rolls the OSC 7501 states of the session's panes
|
|
24
|
+
up to the strongest: `blocked`, `error`, `working`, `done` or `idle`. Empty
|
|
25
|
+
(plain tmux, or no pane reports) means no state. An idle session shows no
|
|
26
|
+
state; muster only counts idle agents in the breakdown of a session row.
|
|
27
|
+
`waiting` and `crashed` come from murmur's snapshot only.
|
|
28
|
+
|
|
29
|
+
## Richer view with a current murmur
|
|
30
|
+
|
|
31
|
+
When the installed murmur supports it, muster also reads `murmur status --json
|
|
32
|
+
--cached` once per open. The read is cache-only, has a one second timeout, and
|
|
33
|
+
runs while muster asks tmux. When a peer was last fetched over 20 seconds ago or
|
|
34
|
+
is stale, a detached low-priority `murmur collect --quiet --floored` warms the
|
|
35
|
+
cache for the next open. Then:
|
|
36
|
+
|
|
37
|
+
- a session row shows how many agents are in each state (`2 working, 1 done`
|
|
38
|
+
as glyph and count) instead of only the strongest state;
|
|
39
|
+
- agents that need attention (crashed, error, blocked, done) get their own rows
|
|
40
|
+
at the top of the all view, in murmur's order. Enter on one selects its pane
|
|
41
|
+
and switches to it when the picker runs inside that agent's tmux server;
|
|
42
|
+
any other agent (another host or server, or a picker outside tmux) goes
|
|
43
|
+
through `murmur jump`.
|
|
44
|
+
|
|
45
|
+
Agent rows need murmur's `jump` command, which every murmur that publishes
|
|
46
|
+
`jump_target` has. A remote agent counts under the
|
|
47
|
+
local session that holds its ssh attachment.
|
|
48
|
+
|
|
49
|
+
### Safety rules
|
|
50
|
+
|
|
51
|
+
muster acts on a pane itself only when it has proven the agent's tmux server is
|
|
52
|
+
the one it talks to (the `MUSTER_TMUX_SOCKET_*` variables, else the socket in
|
|
53
|
+
`$TMUX`, else the default, resolved once when muster starts); everything else
|
|
54
|
+
goes through `murmur jump`. A failed jump stays on screen for a moment and
|
|
55
|
+
shows as a tmux message.
|
|
56
|
+
|
|
57
|
+
muster probes for this: `status --json --cached` must succeed, with well-formed
|
|
58
|
+
panes that carry `jump_target`. It never compares versions. A malformed
|
|
59
|
+
snapshot is ignored as a whole. With no murmur, or an older one,
|
|
60
|
+
everything works from `#{session_program_state}`.
|
|
61
|
+
|
|
62
|
+
## Agents view
|
|
63
|
+
|
|
64
|
+
`prefix a`, `ctrl-g` in the picker, or `muster pick-and-connect --mode agents`
|
|
65
|
+
lists every agent murmur shows by default (human agents, plus crew agents that
|
|
66
|
+
need a human), in murmur's order. `ctrl-g` again shows or hides the other crew
|
|
67
|
+
(orchestrated) agents; the prompt starts with `crew` while they are shown, and
|
|
68
|
+
the setting holds when you switch views and come back (in the all view it
|
|
69
|
+
adds crew agents to the attention rows). Each row has the state,
|
|
70
|
+
the agent's name, its workstream (or tmux session) when that differs from the
|
|
71
|
+
name, a host column (`here` or `→ host`) when any agent is remote, and the age
|
|
72
|
+
of its last update. The prompt counts the shown agents per state.
|
|
73
|
+
|
|
74
|
+
When a peer needs a new ssh session, murmur's notice is the first header line,
|
|
75
|
+
with the `ssh` command that lets murmur reach it again.
|
|
76
|
+
An empty view says so ("No agents", or how many crew agents are hidden) and
|
|
77
|
+
stays open until `esc`. Without murmur, or with one too old for the view, the
|
|
78
|
+
header says that instead.
|
|
79
|
+
|
|
80
|
+
The agents view starts no tmux server and works outside tmux. Enter moves the
|
|
81
|
+
client itself only when the picker runs inside the agent's tmux server;
|
|
82
|
+
otherwise it runs `murmur jump`, which handles other hosts and servers and
|
|
83
|
+
any confirmation it needs on the terminal. The `mux` column says whether an
|
|
84
|
+
agent runs in tmux or Rex; jumping from and to Rex is covered in
|
|
85
|
+
[rex.md](rex.md).
|
|
86
|
+
|
|
87
|
+
### Markers
|
|
88
|
+
|
|
89
|
+
In the agents view the first column's `◆` also marks the agent pane of the
|
|
90
|
+
client that opened the picker (see [keys-and-views.md](keys-and-views.md)).
|
|
91
|
+
|
|
92
|
+
### `--client`
|
|
93
|
+
|
|
94
|
+
Open it through the `prefix a` binding (it passes `--client`), or pass
|
|
95
|
+
`--client` yourself; otherwise errors may show on another client.
|
|
96
|
+
|
|
97
|
+
## Environment
|
|
98
|
+
|
|
99
|
+
`MUSTER_MURMUR` names the murmur to run (default `murmur` on `PATH`) and
|
|
100
|
+
`MUSTER_MURMUR_TIMEOUT` its time limit in seconds (default 1).
|
package/docs/config.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Config
|
|
2
|
+
|
|
3
|
+
Optional. Without a config file muster lists live sessions, zoxide and the scan
|
|
4
|
+
with sensible filters. Copy [examples/config.toml](../examples/config.toml) to
|
|
5
|
+
`~/.config/muster/config.toml` (`$XDG_CONFIG_HOME/muster/config.toml`, or the
|
|
6
|
+
file `$MUSTER_CONFIG` names) to pin sessions or change the filters.
|
|
7
|
+
|
|
8
|
+
## Environment variables
|
|
9
|
+
|
|
10
|
+
`MUSTER_MURMUR` names the murmur to run (default `murmur` on `PATH`) and
|
|
11
|
+
`MUSTER_MURMUR_TIMEOUT` its time limit in seconds (default 1).
|
|
12
|
+
`MUSTER_REX` names the `rex` to run (default `rex` on `PATH`; empty turns Rex
|
|
13
|
+
support off, see [rex.md](rex.md)).
|
|
14
|
+
`MUSTER_TMUX_SOCKET_PATH` / `MUSTER_TMUX_SOCKET_NAME` point muster at another
|
|
15
|
+
tmux server, and `MUSTER_FAST=1` selects the fast test gate; both exist for the
|
|
16
|
+
tests.
|
|
17
|
+
|
|
18
|
+
## Layout and columns
|
|
19
|
+
|
|
20
|
+
The picker fits its columns to the popup. The preview sits right of the list
|
|
21
|
+
from 120 columns, below it from 80, and starts hidden under 80 (`ctrl-/` shows
|
|
22
|
+
it). The name column grows from 16 to 40 cells with the list; a long name keeps
|
|
23
|
+
its last part whole and shortens the start (`projects/te…/demo`), and a long
|
|
24
|
+
path keeps its end (`…ects/team/demo`).
|
|
25
|
+
On a narrow list the window counts go first, then the path. Widths are counted
|
|
26
|
+
in terminal cells, so wide (CJK) names keep the columns aligned. Resizing the
|
|
27
|
+
popup lays the list out again.
|
|
28
|
+
|
|
29
|
+
## Preview
|
|
30
|
+
|
|
31
|
+
The preview of a live session lists every window (active marker, index, agent
|
|
32
|
+
state, name, pane count, directory) above the active pane's contents.
|
|
33
|
+
|
|
34
|
+
## Theme
|
|
35
|
+
|
|
36
|
+
Catppuccin Mocha, hardcoded in `bin/muster` between `THEME BEGIN` / `THEME END`
|
|
37
|
+
markers so a local theme generator can rewrite them.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
ruff and ty are pinned in `pyproject.toml` and `uv.lock` (needs
|
|
4
|
+
[uv](https://docs.astral.sh/uv/)). The tests run on uv's Python here; plain
|
|
5
|
+
`python3 -m unittest discover -s tests` works too. muster itself needs none of
|
|
6
|
+
this: `bin/muster` is a plain script with no dependencies.
|
|
7
|
+
|
|
8
|
+
## Gates
|
|
9
|
+
|
|
10
|
+
Fast, while working and before every commit (a few seconds; skips the tests
|
|
11
|
+
that start a real tmux server or client, or fzf):
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
uv run --frozen ruff check . && uv run --frozen ruff format --check . && uv run --frozen ty check && MUSTER_FAST=1 uv run --frozen python -m unittest discover -s tests
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Slow, the full suite with the live tmux and fzf tests, before a merge or a
|
|
18
|
+
release. Run it through `muzzle run --` where muzzle is installed, so it waits
|
|
19
|
+
its turn on a busy machine:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
muzzle run -- uv run --frozen python -m unittest discover -s tests
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Targeted, the live tests for one area (`-k` matches class or test names):
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
muzzle run -- uv run --frozen python -m unittest discover -s tests -k LiveTmux -k RealFzf
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Every test that starts tmux kills the server and its panes' processes in
|
|
32
|
+
cleanup, and a run that ends early (a timeout, ctrl-c) kills the rest; a run
|
|
33
|
+
leaves no test servers or shells behind. Waits poll for the state they need,
|
|
34
|
+
for up to a minute, instead of sleeping a fixed time.
|
|
35
|
+
|
|
36
|
+
## Releasing
|
|
37
|
+
|
|
38
|
+
Releases are git tags; see [RELEASING.md](../RELEASING.md) and
|
|
39
|
+
[CHANGELOG.md](../CHANGELOG.md).
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Keys and views
|
|
2
|
+
|
|
3
|
+
## tmux keys
|
|
4
|
+
|
|
5
|
+
| Prefix + | Does | Option |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| `s` | Picker popup | `@muster_key_pick` |
|
|
8
|
+
| `a` | Picker popup, agents view | `@muster_key_agents` |
|
|
9
|
+
| `g` | Last session | `@muster_key_last` |
|
|
10
|
+
| `T` | Session rooted at the current pane's directory | `@muster_key_root` |
|
|
11
|
+
|
|
12
|
+
Set an option before TPM runs to move a key, or to `""` to leave it unbound.
|
|
13
|
+
Sourcing `muster.tmux` again after a change releases the key it bound before
|
|
14
|
+
(unless you have rebound that key yourself).
|
|
15
|
+
[mu-crew/dotfiles](https://github.com/mu-crew/dotfiles) sets these for you from
|
|
16
|
+
its own `@mu_crew_key_session_*` options, so configure them there if you use it.
|
|
17
|
+
|
|
18
|
+
```tmux
|
|
19
|
+
set -g @muster_key_pick 'f'
|
|
20
|
+
set -g @muster_key_last ''
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Inside the picker
|
|
24
|
+
|
|
25
|
+
| Key | Does |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `ctrl-a` | All view: pinned, live, agents needing attention, zoxide (the default) |
|
|
28
|
+
| `ctrl-s` | Sessions view: pinned and live sessions |
|
|
29
|
+
| `ctrl-g` | Agents view; again in the agents view: show or hide crew agents |
|
|
30
|
+
| `ctrl-f` | Find view: directory scan under `$HOME` |
|
|
31
|
+
| `ctrl-x` | Kill the highlighted session (tmux or Rex session rows; refuses the tmux session you are in); on a crashed agent, dismiss the crash |
|
|
32
|
+
| `ctrl-/` | Show or hide the preview |
|
|
33
|
+
| `tab` / `shift-tab` | Down / up |
|
|
34
|
+
| `enter` | Switch to the row, creating the session first if needed, or jump to the agent |
|
|
35
|
+
| `esc` / `ctrl-c` | Abort |
|
|
36
|
+
|
|
37
|
+
The first column marks where you are: `◆` is the session (and, in the agents
|
|
38
|
+
view, the agent pane) of the client that opened the picker, and `◇` is a
|
|
39
|
+
session another client has attached.
|
|
40
|
+
|
|
41
|
+
## Opening from the cache
|
|
42
|
+
|
|
43
|
+
The popup first shows the rows that the last open of the same view left
|
|
44
|
+
behind, then replaces them with a fresh list as soon as it is ready. The fresh
|
|
45
|
+
list is usually ready within a few hundred milliseconds, or as soon as murmur
|
|
46
|
+
answers. It keeps your query, and you can type and move at once. A view key or
|
|
47
|
+
`ctrl-x` pressed before it arrives keeps the list it asked for. If you press Enter before the fresh list
|
|
48
|
+
arrives, the popup closes and muster looks the row up again in a fresh list: it
|
|
49
|
+
acts on the row as it is now, or says the row is gone. The cache lives in
|
|
50
|
+
`$XDG_STATE_HOME/muster/views/` (`~/.local/state/muster/views/`). There is one
|
|
51
|
+
file per view, tmux server, popup width and muster version. A first open, or an
|
|
52
|
+
open at a new width, lists fresh rows as before.
|
|
53
|
+
|
|
54
|
+
## Command line
|
|
55
|
+
|
|
56
|
+
`bin/muster` also works on its own, outside a popup: `muster pick-and-connect`.
|
|
57
|
+
|
|
58
|
+
`muster list|picker|pick-and-connect --mode` takes `all`, `sessions`, `find` or
|
|
59
|
+
`agents`; `muster list --mode agents --crew` includes crew agents. `muster last`
|
|
60
|
+
says "muster: no previous session" in tmux when there is none, and
|
|
61
|
+
`muster kill --kind=tmux --session-id='$N'` is `ctrl-x` from a shell.
|
|
62
|
+
`muster --help` lists the commands. `muster --version` prints the version.
|
|
63
|
+
|
|
64
|
+
See [sessions.md](sessions.md) for what each session row shows and how
|
|
65
|
+
picking a directory finds its session, and [agents.md](agents.md) for the
|
|
66
|
+
agents view.
|
package/docs/rex.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Rex
|
|
2
|
+
|
|
3
|
+
muster works the same from a tmux client and from a [Rex](https://www.superlogical.com/rex)
|
|
4
|
+
pane: one picker lists tmux sessions, Rex sessions, directories and agents,
|
|
5
|
+
and Enter takes you to the row in whichever multiplexer holds it.
|
|
6
|
+
|
|
7
|
+
## When muster is in Rex
|
|
8
|
+
|
|
9
|
+
muster counts as running in Rex when `TERM_PROGRAM=rex` and Rex has set
|
|
10
|
+
`$REX_BLOCK` (older Rex builds set `$REX_SESSION` instead), and `$TMUX` is
|
|
11
|
+
unset. A tmux client running in a Rex tab counts as tmux, because that is
|
|
12
|
+
where its keys go.
|
|
13
|
+
|
|
14
|
+
## Rex session rows
|
|
15
|
+
|
|
16
|
+
Live Rex sessions on this machine are listed in the all and sessions views,
|
|
17
|
+
after the tmux sessions, with a `■` icon and `rex` where a tmux row shows its
|
|
18
|
+
window and pane counts.
|
|
19
|
+
|
|
20
|
+
They are listed only when this machine's Rex server has a Rex.app connected
|
|
21
|
+
(`rex client ls`; with `$REX_CLIENT` set, that client). Rex has no terminal
|
|
22
|
+
attach, so on a machine with no Rex.app, such as a Linux box running a
|
|
23
|
+
headless Rex server, nothing could show a Rex session and none are listed.
|
|
24
|
+
|
|
25
|
+
With murmur, a Rex row takes the strongest non-idle state of the agents in its
|
|
26
|
+
panes, as a tmux row does. The preview lists the session's windows (`*` marks
|
|
27
|
+
the active one) above the contents of the active window's focused pane.
|
|
28
|
+
`ctrl-x` on a Rex row runs `rex kill` on that session.
|
|
29
|
+
|
|
30
|
+
## Enter
|
|
31
|
+
|
|
32
|
+
| Row | From tmux | From Rex |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| Rex session | Shows it in Rex.app and, on macOS, brings Rex.app to the front | Shows it |
|
|
35
|
+
| Live tmux session | Switches the client | Opens it in a new Rex tab (`tmux attach-session`) and shows that tab |
|
|
36
|
+
| Pinned, zoxide or find row | Switches to its tmux session, creating it first if needed | Shows the live Rex or tmux session of that name (tmux in a new tab); otherwise creates a Rex session |
|
|
37
|
+
| Agent | See [agents.md](agents.md) | `murmur jump`; a tmux agent opens in a new Rex tab, which muster shows |
|
|
38
|
+
|
|
39
|
+
A Rex session created from a directory row gets the row's name and starts in
|
|
40
|
+
its directory, so it never carries one of Rex's generated names. A pinned
|
|
41
|
+
session's `startup` is typed into the new session's shell, as tmux's
|
|
42
|
+
`send-keys` would, so quitting the program leaves the shell. Its `split`
|
|
43
|
+
becomes a Rex split of that first pane: `vertical` to the right, `horizontal`
|
|
44
|
+
below.
|
|
45
|
+
|
|
46
|
+
## Agents
|
|
47
|
+
|
|
48
|
+
The agents view has a `mux` column (`tmux` or `rex`), and the all view's
|
|
49
|
+
attention rows name the multiplexer too. A Rex agent is reached through
|
|
50
|
+
`murmur jump`, which needs a Rex.app on this machine; without one, murmur
|
|
51
|
+
releases after 3.1.2 say so instead of jumping.
|
|
52
|
+
|
|
53
|
+
murmur 3.1.1 and older do not handle a jump from a Rex pane completely: 3.1.0
|
|
54
|
+
misses current Rex panes, and neither shows the tab it opens. muster covers both,
|
|
55
|
+
passing `$REX_BLOCK` as `$REX_SESSION` to `murmur jump` and showing the new tab
|
|
56
|
+
afterwards. With murmur 3.1.2 or later both steps are redundant and harmless.
|
|
57
|
+
|
|
58
|
+
## Opening muster in Rex
|
|
59
|
+
|
|
60
|
+
Run `muster pick-and-connect` in any Rex pane, or `muster pick-and-connect
|
|
61
|
+
--mode agents` for the agents view. [mu-crew/dotfiles](https://github.com/mu-crew/dotfiles)
|
|
62
|
+
binds both in a floating Rex layer, the way `prefix s` and `prefix a` open a
|
|
63
|
+
tmux popup: `cmd+b s` for the picker, and `cmd+b a` or `cmd+j` for the agents
|
|
64
|
+
view (see its `docs/rex.md`).
|
|
65
|
+
|
|
66
|
+
## Environment
|
|
67
|
+
|
|
68
|
+
| Variable | Effect |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `MUSTER_REX` | The `rex` to run (default `rex` on `PATH`). Set it empty to turn Rex support off. |
|
|
71
|
+
| `REX_CLIENT` | The Rex.app client to show sessions in, by label or ID. Unset, muster uses the Rex.app running on this machine, even when other machines' Rex.apps are attached to the same server; sessions are shown nowhere else. With `$REX_CLIENT` set, that client is used as named. Rex rows are listed only when there is a client to show them in. |
|
|
72
|
+
| `REX_SERVER` | Ignored: muster always talks to this machine's Rex server. |
|
package/docs/sessions.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Sessions
|
|
2
|
+
|
|
3
|
+
## Rows
|
|
4
|
+
|
|
5
|
+
Live sessions are listed most recently active first, after the pinned ones
|
|
6
|
+
(which keep their config order). A live session's row counts its windows and
|
|
7
|
+
panes (`3w 5p`) and shows its active pane's directory, with a dim `+N` when its
|
|
8
|
+
windows sit in N other directories. A zoxide or scan directory that a live
|
|
9
|
+
session is rooted at, or has a window in, is not listed again: that session's
|
|
10
|
+
row stands for it. The preview of a live session lists every window (active
|
|
11
|
+
marker, index, agent state, name, pane count, directory) above the active
|
|
12
|
+
pane's contents. Rex sessions get rows of their own (`■`), described in
|
|
13
|
+
[rex.md](rex.md).
|
|
14
|
+
|
|
15
|
+
## Session reuse by path and name collisions
|
|
16
|
+
|
|
17
|
+
Picking a directory reuses the live session rooted at that directory, matched
|
|
18
|
+
by its real path (muster starts sessions with `new-session -c <realpath>`) or by
|
|
19
|
+
the path as given, which covers sessions an older muster started through a
|
|
20
|
+
symlink. Two directories whose names sanitize alike (`a.b`, `a_b`) get
|
|
21
|
+
separate sessions, the second suffixed `-2`. One limitation: if a symlink was
|
|
22
|
+
retargeted after its session was created, connecting through that same symlink
|
|
23
|
+
string reuses the old session. Connecting through the real path is exact.
|
|
24
|
+
Directories with a newline or carriage return in the name are not offered in
|
|
25
|
+
the scan, but `muster connect` handles them.
|
|
26
|
+
|
|
27
|
+
## Kill and last
|
|
28
|
+
|
|
29
|
+
`ctrl-x` in the picker kills the highlighted session (session rows only; it
|
|
30
|
+
refuses the session you are in); `muster kill --kind=tmux --session-id='$N'`
|
|
31
|
+
does the same from a shell. `prefix g` (`muster last`) switches to the last
|
|
32
|
+
session, and says "muster: no previous session" in tmux when there is none.
|
|
33
|
+
|
|
34
|
+
## Server lifetime
|
|
35
|
+
|
|
36
|
+
When muster starts the tmux server from inside a unit of the systemd user
|
|
37
|
+
manager, it runs the server under `systemd-run --user --scope`. A shell in a
|
|
38
|
+
`foot --server` window is the usual case. The server would otherwise stay in
|
|
39
|
+
that unit's cgroup, and a stop or restart of the unit would kill every session.
|
|
40
|
+
A login shell (ssh, a tty) sits in logind's own session scope, which tmux
|
|
41
|
+
already outlives at logout, so muster starts plain `tmux` there. Moving that
|
|
42
|
+
server under `user@.service` would end it about 10 s after the last logout
|
|
43
|
+
unless lingering is on. macOS, containers and hosts without `systemd-run` also
|
|
44
|
+
get plain `tmux`.
|
|
45
|
+
|
|
46
|
+
With no server running, the picker starts one the same way (`start-server`)
|
|
47
|
+
before it lists live sessions, so a tmux that restores saved sessions at server
|
|
48
|
+
start shows them. When creating a session, muster checks again after starting
|
|
49
|
+
the server and switches to the session if it came back, instead of running
|
|
50
|
+
`new-session`. A restored session therefore skips its configured `startup`
|
|
51
|
+
and `split`: those run only when muster creates the session. Plain tmux has no
|
|
52
|
+
snapshot: `start-server` exits at once and nothing changes.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# ~/.config/muster/config.toml -- every key is optional.
|
|
2
|
+
|
|
3
|
+
# Directories to scan in find mode (^f), relative to $HOME.
|
|
4
|
+
find_max_depth = 2
|
|
5
|
+
# {path} is replaced with the shell-quoted directory. Default: eza if
|
|
6
|
+
# installed, else ls -la.
|
|
7
|
+
preview_command = "eza --all --git --icons --color=always {path}"
|
|
8
|
+
# Open the picker on the sessions view once you have at least this many.
|
|
9
|
+
# 0 disables.
|
|
10
|
+
live_session_threshold = 5
|
|
11
|
+
# true: query tokens match as literal substrings. Prefix a token with ' for
|
|
12
|
+
# fuzzy. false: classic fzf fuzzy matching.
|
|
13
|
+
fzf_exact = false
|
|
14
|
+
# Path segments that hide a directory and everything under it.
|
|
15
|
+
blacklist = [".cache", ".config", ".local", "Library", "tmp"]
|
|
16
|
+
noisy_basenames = ["node_modules", "target", "dist", "build", ".git"]
|
|
17
|
+
|
|
18
|
+
# Pinned sessions: always listed, created on first pick.
|
|
19
|
+
[[sessions]]
|
|
20
|
+
name = "notes"
|
|
21
|
+
path = "~/notes"
|
|
22
|
+
startup = "nvim" # typed into the first pane
|
|
23
|
+
split = "vertical" # "", "vertical" (side by side) or "horizontal"
|
package/muster.tmux
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# TPM entry point. Binds under the prefix; override a key before TPM runs:
|
|
3
|
+
# set -g @muster_key_pick s # picker popup
|
|
4
|
+
# set -g @muster_key_agents a # picker popup, agents view
|
|
5
|
+
# set -g @muster_key_last g # last session
|
|
6
|
+
# set -g @muster_key_root T # session rooted at the pane's cwd
|
|
7
|
+
# Set a key to "" to leave it unbound.
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
11
|
+
muster="$dir/bin/muster"
|
|
12
|
+
|
|
13
|
+
opt() {
|
|
14
|
+
local value
|
|
15
|
+
value=$(tmux show-option -gqv "$1")
|
|
16
|
+
# Unset means the default; an explicit empty string means "do not bind".
|
|
17
|
+
if tmux show-options -g | grep -q "^$1 "; then
|
|
18
|
+
printf '%s' "$value"
|
|
19
|
+
else
|
|
20
|
+
printf '%s' "$2"
|
|
21
|
+
fi
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# muster_bind NAME KEY NOTE COMMAND...: bind KEY, or with KEY "" bind nothing.
|
|
25
|
+
# Either way a key this script bound for NAME on an earlier source is released
|
|
26
|
+
# first, so re-sourcing after changing an option takes effect. The key is
|
|
27
|
+
# recorded in @muster_bound_NAME; it is unbound only while it still carries our
|
|
28
|
+
# note, so a key the user rebound since is left alone.
|
|
29
|
+
muster_bind() {
|
|
30
|
+
local name=$1 key=$2 note=$3 prev
|
|
31
|
+
shift 3
|
|
32
|
+
prev=$(tmux show-option -gqv "@muster_bound_$name")
|
|
33
|
+
if [[ -n $prev && $prev != "$key" ]] &&
|
|
34
|
+
tmux list-keys -N -T prefix "$prev" 2>/dev/null | grep -qF "$note"; then
|
|
35
|
+
tmux unbind-key -T prefix "$prev"
|
|
36
|
+
fi
|
|
37
|
+
if [[ -n $key ]]; then
|
|
38
|
+
tmux bind-key -N "$note" "$key" "$@"
|
|
39
|
+
tmux set-option -g "@muster_bound_$name" "$key"
|
|
40
|
+
else
|
|
41
|
+
tmux set-option -gu "@muster_bound_$name"
|
|
42
|
+
fi
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# quote WORD: WORD for sh, in single quotes; a ' inside is closed, escaped
|
|
46
|
+
# and reopened.
|
|
47
|
+
quote() {
|
|
48
|
+
local q="'\\''"
|
|
49
|
+
printf "'%s'" "${1//\'/$q}"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# Each binding's line passes through two parsers. run-shell format-expands it
|
|
53
|
+
# (so a literal "#" is written "##") and hands it to sh -c; display-popup hands
|
|
54
|
+
# its own argument to a shell again. The plugin path is quoted for each layer,
|
|
55
|
+
# so a directory like "Plugin's path" works. run-shell expands #{client_name}
|
|
56
|
+
# (display-popup's own command is not expanded), so the picker learns which
|
|
57
|
+
# client opened it and failures show there, not on whichever client tmux calls
|
|
58
|
+
# current. A client name is a tty path or "client-N": nothing a shell would
|
|
59
|
+
# split. #{pane_id} likewise: run-shell hands the expanded line to sh -c, and
|
|
60
|
+
# a path can carry a newline, so muster reads the cwd for the pane id itself.
|
|
61
|
+
exe=$(quote "$muster")
|
|
62
|
+
exe=${exe//#/##}
|
|
63
|
+
popup() {
|
|
64
|
+
local inner="$exe pick-and-connect $1--client '#{client_name}'"
|
|
65
|
+
printf '%s' "tmux display-popup -E -c '#{client_name}' -w 90% -h 85% $(quote "$inner")"
|
|
66
|
+
}
|
|
67
|
+
muster_bind pick "$(opt @muster_key_pick s)" "session picker (muster)" \
|
|
68
|
+
run-shell -b "$(popup "")"
|
|
69
|
+
muster_bind agents "$(opt @muster_key_agents a)" "agent picker (muster)" \
|
|
70
|
+
run-shell -b "$(popup "--mode agents ")"
|
|
71
|
+
muster_bind last "$(opt @muster_key_last g)" "last session (muster)" \
|
|
72
|
+
run-shell -b "$exe last"
|
|
73
|
+
muster_bind root "$(opt @muster_key_root T)" "session at pane cwd (muster)" \
|
|
74
|
+
run-shell -b "$exe connect --pane '#{pane_id}'"
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mu-crew/muster",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Pick a tmux or Rex session, pinned, live or from zoxide, or an agent on any machine murmur sees. Also a TPM plugin.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "Martin Trojer <martin.trojer@gmail.com>",
|
|
10
|
+
"homepage": "https://github.com/mu-crew/muster",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/mu-crew/muster.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/mu-crew/muster/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"tmux",
|
|
20
|
+
"rex",
|
|
21
|
+
"sessions",
|
|
22
|
+
"picker",
|
|
23
|
+
"agents",
|
|
24
|
+
"fzf"
|
|
25
|
+
],
|
|
26
|
+
"bin": {
|
|
27
|
+
"muster": "bin/muster"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"bin/muster",
|
|
31
|
+
"muster.tmux",
|
|
32
|
+
"docs",
|
|
33
|
+
"examples",
|
|
34
|
+
"CHANGELOG.md",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"README.md"
|
|
37
|
+
]
|
|
38
|
+
}
|