libtmux 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/README.md +270 -93
- data/lib/libtmux/capabilities.rb +86 -2
- data/lib/libtmux/capture.rb +6 -11
- data/lib/libtmux/control.rb +3 -0
- data/lib/libtmux/entity.rb +176 -3
- data/lib/libtmux/errors.rb +20 -1
- data/lib/libtmux/operations.rb +7 -0
- data/lib/libtmux/option_catalog.rb +54 -0
- data/lib/libtmux/options.rb +39 -11
- data/lib/libtmux/owned.rb +11 -0
- data/lib/libtmux/process.rb +40 -11
- data/lib/libtmux/program.rb +478 -0
- data/lib/libtmux/server.rb +80 -17
- data/lib/libtmux/terminal.rb +6 -1
- data/lib/libtmux/text_wait.rb +101 -0
- data/lib/libtmux/tmux_version.rb +24 -2
- data/lib/libtmux/version.rb +1 -1
- data/lib/libtmux.rb +6 -0
- data/libexec/program_child.rb +60 -0
- data/schema/option-catalog.json +1723 -0
- data/sig/control.rbs +2 -1
- data/sig/libtmux.rbs +81 -6
- data/sig/option_catalog.rbs +26 -0
- data/sig/program.rbs +47 -0
- data/sig/terminal.rbs +1 -0
- metadata +17 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82b7f1a458a6a7b43a8b6520e292aeea8bd750587101b29ecf0d2c94cb9ee333
|
|
4
|
+
data.tar.gz: 38637e53ffc48f2ea65e30f621c1720d3fcfb924a17ce793f7626dc66b72b110
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb757ca2ed5253502fa97c767f18a10f09ccba0841cd7710cce3706650ee3cea5ca834267b6730772525504b8acec9623c86071f07154108ab6e1d3408146862
|
|
7
|
+
data.tar.gz: 780145d196842bab9657e9bca3946594cb475f08fd45b4ceb3cb40018a30fd4f5e4198298275bfc88de241d47e1de88800539c7222e358afdb386167ad2a45d9
|
data/CHANGELOG.md
CHANGED
|
@@ -9,7 +9,26 @@ The gems are released together at one version, so every release has a section
|
|
|
9
9
|
here. Changes that span gems, such as documentation, CI and release tooling, are
|
|
10
10
|
in the [main changelog](../../CHANGELOG.md).
|
|
11
11
|
|
|
12
|
-
## 0.1.
|
|
12
|
+
## 0.1.4 (unreleased)
|
|
13
|
+
|
|
14
|
+
## 0.1.3 (2026-12-05)
|
|
15
|
+
|
|
16
|
+
- `CommandError` includes the command and the first printable line of tmux's
|
|
17
|
+
error. The exception still carries the full native result. (#173)
|
|
18
|
+
- Typed option reads and writes accept dotted or colon-separated user keys on
|
|
19
|
+
tmux 3.7. The session guide shows how to read the name stored by the daemon.
|
|
20
|
+
(#181)
|
|
21
|
+
- Option reads preserve literal asterisks and spaces in user option names
|
|
22
|
+
while reporting whether the value is inherited. (#182)
|
|
23
|
+
- OptionCatalog exposes the built-in option and hook definitions from tmux
|
|
24
|
+
3.8, including option types, ranges, choices and scopes. (#191)
|
|
25
|
+
- `Server#write_buffer` raises `UnsupportedFeatureError` for an empty payload
|
|
26
|
+
before sending it to tmux. Nonempty writes keep their existing behavior.
|
|
27
|
+
(#172)
|
|
28
|
+
- Session, window and pane creation can run the daemon's configured command or
|
|
29
|
+
shell. Omit the session or window name to let tmux choose it. (#186)
|
|
30
|
+
- `Server#list_windows` and `Server#list_panes` return empty collections when
|
|
31
|
+
their bound daemon is running without sessions. (#174)
|
|
13
32
|
|
|
14
33
|
## 0.1.2 (2026-11-04)
|
|
15
34
|
|
data/README.md
CHANGED
|
@@ -19,8 +19,10 @@ as handles, [snapshots][snapshot] you filter in plain Ruby, and
|
|
|
19
19
|
[Guides](https://libtmux.org/en/ruby/latest/guides/) ·
|
|
20
20
|
[RubyGems](https://rubygems.org/gems/libtmux)
|
|
21
21
|
|
|
22
|
-
[](https://github.com/libtmux/libtmux-ruby/actions/workflows/compatibility.yml)
|
|
23
23
|
[](https://rubygems.org/gems/libtmux)
|
|
24
|
+
[](https://libtmux.org/en/ruby/)
|
|
25
|
+
[](https://github.com/libtmux/libtmux-ruby/blob/master/LICENSE)
|
|
24
26
|
|
|
25
27
|
</div>
|
|
26
28
|
|
|
@@ -58,15 +60,16 @@ $ gem install libtmux
|
|
|
58
60
|
```
|
|
59
61
|
|
|
60
62
|
This program creates a session, adds a window, splits it, and prints each
|
|
61
|
-
window with its panes
|
|
62
|
-
server when the block exits, and the snapshot stays readable afterward:
|
|
63
|
+
window with its panes:
|
|
63
64
|
|
|
64
65
|
<!-- example: quickstart/main -->
|
|
65
66
|
```ruby
|
|
66
67
|
require "libtmux"
|
|
67
68
|
|
|
68
69
|
snapshot = LibTmux::Server.start do |server|
|
|
69
|
-
session = server.new_session(
|
|
70
|
+
session = server.new_session(
|
|
71
|
+
name: "work", window_name: "main", command: ["/bin/cat"]
|
|
72
|
+
)
|
|
70
73
|
window = session.new_window(name: "logs", command: ["/bin/cat"])
|
|
71
74
|
window.split(direction: :horizontal, size: "40%", command: ["/bin/cat"])
|
|
72
75
|
|
|
@@ -79,6 +82,12 @@ end
|
|
|
79
82
|
```
|
|
80
83
|
<!-- /example -->
|
|
81
84
|
|
|
85
|
+
Save it as `quickstart.rb` and run it:
|
|
86
|
+
|
|
87
|
+
```console
|
|
88
|
+
$ ruby quickstart.rb
|
|
89
|
+
```
|
|
90
|
+
|
|
82
91
|
It prints:
|
|
83
92
|
|
|
84
93
|
```text
|
|
@@ -86,9 +95,10 @@ main: %0
|
|
|
86
95
|
logs: %1, %2
|
|
87
96
|
```
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
[`Server.start`][server-start] gives the program a tmux server of its own, on
|
|
99
|
+
its own socket with an empty configuration, and closes it when the block exits.
|
|
100
|
+
It never touches a tmux you already use. Requiring the gem starts no tmux
|
|
101
|
+
process.
|
|
92
102
|
|
|
93
103
|
## Find sessions, windows, and panes
|
|
94
104
|
|
|
@@ -127,10 +137,22 @@ raises [`CommandError`][commanderror].
|
|
|
127
137
|
Read the server once, then filter that read with
|
|
128
138
|
[`where`][selection-where], [`select`][selection-select],
|
|
129
139
|
[`one`][selection-one] and [`one_or_nil`][selection-one_or_nil]. These queries
|
|
130
|
-
make no tmux calls
|
|
140
|
+
make no tmux calls:
|
|
131
141
|
|
|
132
142
|
<!-- example: quickstart/queries -->
|
|
133
143
|
```ruby
|
|
144
|
+
require "libtmux"
|
|
145
|
+
|
|
146
|
+
snapshot = LibTmux::Server.start do |server|
|
|
147
|
+
session = server.new_session(
|
|
148
|
+
name: "work", window_name: "main", command: ["/bin/cat"]
|
|
149
|
+
)
|
|
150
|
+
window = session.new_window(name: "logs", command: ["/bin/cat"])
|
|
151
|
+
window.split(direction: :horizontal, size: "40%", command: ["/bin/cat"])
|
|
152
|
+
|
|
153
|
+
server.snapshot
|
|
154
|
+
end
|
|
155
|
+
|
|
134
156
|
panes = snapshot.panes
|
|
135
157
|
active_ids = panes.where(active: true).map(&:id)
|
|
136
158
|
wide_panes = panes.select { |pane| pane.width >= 40 }
|
|
@@ -138,9 +160,23 @@ panes_by_window = panes.group_by { |pane| pane.window.name }
|
|
|
138
160
|
|
|
139
161
|
logs = snapshot.windows.one(name: "logs")
|
|
140
162
|
missing = snapshot.windows.one_or_nil(name: "missing")
|
|
163
|
+
|
|
164
|
+
puts "active: #{active_ids.join(', ')}"
|
|
165
|
+
puts "wide: #{wide_panes.map(&:id).join(', ')}"
|
|
166
|
+
puts "logs panes: #{logs.panes.length}"
|
|
167
|
+
puts "missing: #{missing.inspect}"
|
|
141
168
|
```
|
|
142
169
|
<!-- /example -->
|
|
143
170
|
|
|
171
|
+
It prints:
|
|
172
|
+
|
|
173
|
+
```text
|
|
174
|
+
active: %0, %1
|
|
175
|
+
wide: %0, %1
|
|
176
|
+
logs panes: 2
|
|
177
|
+
missing: nil
|
|
178
|
+
```
|
|
179
|
+
|
|
144
180
|
`one` raises [`NoMatchError`][nomatcherror] or
|
|
145
181
|
[`MultipleMatchesError`][multiplematcheserror] unless exactly one record
|
|
146
182
|
matches. `one_or_nil` returns `nil` for no match and still rejects duplicates.
|
|
@@ -152,8 +188,7 @@ lists every query field and wire name.
|
|
|
152
188
|
### [`Server#search_panes`][server-search_panes]: the matching panes in one call
|
|
153
189
|
|
|
154
190
|
`search_panes` captures the server and answers a selection of the panes whose
|
|
155
|
-
fields match `where:`.
|
|
156
|
-
without running tmux. This program also uses the snapshot queries above:
|
|
191
|
+
fields match `where:`. This program also uses the snapshot queries above:
|
|
157
192
|
|
|
158
193
|
<!-- example: api_query/main -->
|
|
159
194
|
```ruby
|
|
@@ -181,13 +216,45 @@ missing session: true
|
|
|
181
216
|
matching pane: %0
|
|
182
217
|
```
|
|
183
218
|
|
|
219
|
+
### [`Server#explain_panes`][server-explain_panes]: what runs in tmux, what runs in Ruby
|
|
220
|
+
|
|
221
|
+
`explain_panes` returns the plan for a pane query and sends nothing to tmux.
|
|
222
|
+
Today tmux returns the whole server and Ruby applies every criterion:
|
|
223
|
+
|
|
224
|
+
<!-- example: api_explain_panes/main -->
|
|
225
|
+
```ruby
|
|
226
|
+
require "libtmux"
|
|
227
|
+
|
|
228
|
+
LibTmux::Server.start do |server|
|
|
229
|
+
server.new_session(name: "work", command: ["/bin/cat"])
|
|
230
|
+
criteria = {active: true}
|
|
231
|
+
plan = server.explain_panes(where: criteria)
|
|
232
|
+
puts "tmux reads: #{plan.fetch(:capture)}"
|
|
233
|
+
puts "tmux filters: #{plan.fetch(:pushed) || 'nothing'}"
|
|
234
|
+
puts "Ruby filters: #{plan.fetch(:residual).fetch('where').keys.join(', ')}"
|
|
235
|
+
puts "matching panes: #{server.search_panes(where: criteria).length}"
|
|
236
|
+
end
|
|
237
|
+
```
|
|
238
|
+
<!-- /example -->
|
|
239
|
+
|
|
240
|
+
It prints:
|
|
241
|
+
|
|
242
|
+
```text
|
|
243
|
+
tmux reads: full_graph
|
|
244
|
+
tmux filters: nothing
|
|
245
|
+
Ruby filters: active
|
|
246
|
+
matching panes: 1
|
|
247
|
+
```
|
|
248
|
+
|
|
184
249
|
## Create sessions, windows, and panes
|
|
185
250
|
|
|
186
251
|
### [`Server#new_session`][server-new_session]: a session and its first window
|
|
187
252
|
|
|
188
|
-
`
|
|
189
|
-
|
|
190
|
-
|
|
253
|
+
Omit `name:` to let tmux name the detached session. Omit `command:` to
|
|
254
|
+
use tmux's `default-command` or, when empty, `default-shell`. Pass an argv
|
|
255
|
+
array to run a specific program. The receipt includes the session, window
|
|
256
|
+
and pane IDs. Keep the session reference to target it by ID and read the
|
|
257
|
+
effective name from a snapshot.
|
|
191
258
|
|
|
192
259
|
<!-- example: api_new_session/main -->
|
|
193
260
|
```ruby
|
|
@@ -197,7 +264,9 @@ LibTmux::Server.start do |server|
|
|
|
197
264
|
created = server.new_session(
|
|
198
265
|
name: "work", window_name: "main", command: ["/bin/cat"], receipt: true
|
|
199
266
|
)
|
|
200
|
-
|
|
267
|
+
ref = created.entity.ref
|
|
268
|
+
puts "session: #{ref.id}"
|
|
269
|
+
puts "name: #{server.session(ref).snapshot.name}"
|
|
201
270
|
puts "window: #{created.window.id}"
|
|
202
271
|
puts "pane: #{created.pane.id}"
|
|
203
272
|
end
|
|
@@ -208,6 +277,7 @@ It prints:
|
|
|
208
277
|
|
|
209
278
|
```text
|
|
210
279
|
session: $0
|
|
280
|
+
name: work
|
|
211
281
|
window: @0
|
|
212
282
|
pane: %0
|
|
213
283
|
```
|
|
@@ -215,10 +285,13 @@ pane: %0
|
|
|
215
285
|
Creation returns once tmux has assigned the IDs. It says nothing about whether
|
|
216
286
|
the program started or exited cleanly.
|
|
217
287
|
|
|
288
|
+
More: [Session name behavior by tmux release][behavior-creation].
|
|
289
|
+
|
|
218
290
|
### [`Session#new_window`][session-new_window]: add a window
|
|
219
291
|
|
|
220
292
|
[`Pane#split`][pane-split] and [`Window#split`][window-split] add panes the
|
|
221
|
-
same way. A new window
|
|
293
|
+
same way. A new window accepts the same optional `name:` and `command:`
|
|
294
|
+
as a session. Splits also accept `command:`.
|
|
222
295
|
|
|
223
296
|
<!-- example: api_new_window/main -->
|
|
224
297
|
```ruby
|
|
@@ -257,31 +330,59 @@ The full contract is in [Creation][behavior-creation].
|
|
|
257
330
|
`send_text` types literal text, and [`send_keys`][pane-send_keys] sends tmux key
|
|
258
331
|
names such as `Enter`. [`Pane#capture`][pane-capture] reads the screen.
|
|
259
332
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
333
|
+
Poll the pane until the CLI prompts, then send a reply. This example needs
|
|
334
|
+
tmux 3.6 or newer to read the retained pane's exit status. A
|
|
335
|
+
[control connection][server-open_control] can report output as an event on
|
|
336
|
+
tmux 3.7 or newer.
|
|
263
337
|
|
|
264
338
|
<!-- example: api_capture/main -->
|
|
265
339
|
```ruby
|
|
266
340
|
require "libtmux"
|
|
341
|
+
require "rbconfig"
|
|
342
|
+
|
|
343
|
+
def wait_until(message)
|
|
344
|
+
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + 5
|
|
345
|
+
loop do
|
|
346
|
+
remaining = deadline - Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
347
|
+
raise message unless remaining.positive?
|
|
348
|
+
result = yield remaining
|
|
349
|
+
return result if result
|
|
350
|
+
|
|
351
|
+
sleep [0.02, remaining].min
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
command = [RbConfig.ruby, "-e", <<~'RUBY']
|
|
356
|
+
$stdout.sync = true
|
|
357
|
+
puts "What is your name?"
|
|
358
|
+
name = STDIN.gets or exit 1
|
|
359
|
+
puts "Hello, #{name.chomp}!"
|
|
360
|
+
RUBY
|
|
267
361
|
|
|
268
362
|
LibTmux::Server.start do |server|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
|
|
363
|
+
server.options(scope: :window).set("remain-on-exit", true)
|
|
364
|
+
pane = server.new_session(
|
|
365
|
+
name: "greeting", command: command, receipt: true
|
|
366
|
+
).pane
|
|
367
|
+
|
|
368
|
+
wait_until("CLI did not prompt for a name") do |remaining|
|
|
369
|
+
lines = pane.capture(timeout: remaining).text.lines(chomp: true)
|
|
370
|
+
lines.include?("What is your name?")
|
|
371
|
+
end
|
|
372
|
+
pane.send_text("Ada")
|
|
275
373
|
pane.send_keys("Enter")
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
sleep 0.05
|
|
281
|
-
captured = pane.capture.stdout.lines(chomp: true)
|
|
374
|
+
|
|
375
|
+
status = wait_until("CLI did not report an exit status") do |remaining|
|
|
376
|
+
state = pane.snapshot(timeout: remaining)
|
|
377
|
+
state.dead_status if state.dead?
|
|
282
378
|
end
|
|
283
|
-
raise "
|
|
284
|
-
|
|
379
|
+
raise "CLI exited with status #{status}" unless status == 0
|
|
380
|
+
|
|
381
|
+
greeting = pane.capture(start: "-").text.lines(chomp: true).find do |line|
|
|
382
|
+
line == "Hello, Ada!"
|
|
383
|
+
end
|
|
384
|
+
raise "CLI did not greet Ada" unless greeting
|
|
385
|
+
puts greeting
|
|
285
386
|
end
|
|
286
387
|
```
|
|
287
388
|
<!-- /example -->
|
|
@@ -289,10 +390,10 @@ end
|
|
|
289
390
|
It prints:
|
|
290
391
|
|
|
291
392
|
```text
|
|
292
|
-
|
|
393
|
+
Hello, Ada!
|
|
293
394
|
```
|
|
294
395
|
|
|
295
|
-
-
|
|
396
|
+
- `remain-on-exit` keeps the screen and exit status available after the CLI exits.
|
|
296
397
|
- `capture` returns the visible screen. `start:` and `finish:` choose a range,
|
|
297
398
|
and `join:` joins wrapped lines.
|
|
298
399
|
- `escapes:`, `escape_bytes:`, `preserve_trailing:` and `trim_trailing:` change
|
|
@@ -306,6 +407,65 @@ libtmux capture ready
|
|
|
306
407
|
|
|
307
408
|
The full contract is in [Pane input and capture][behavior-capture].
|
|
308
409
|
|
|
410
|
+
## Check what the daemon supports
|
|
411
|
+
|
|
412
|
+
### [`Server#capabilities`][server-capabilities]: feature requirements and decisions
|
|
413
|
+
|
|
414
|
+
Read the connected daemon's feature report. Use its support query before
|
|
415
|
+
choosing an optional operation, or inspect the required release and refusal.
|
|
416
|
+
|
|
417
|
+
<!-- example: api_capabilities/main -->
|
|
418
|
+
```ruby
|
|
419
|
+
require "libtmux"
|
|
420
|
+
|
|
421
|
+
LibTmux::Server.start do |server|
|
|
422
|
+
report = server.capabilities
|
|
423
|
+
feature = report.feature("layout-json")
|
|
424
|
+
puts "JSON layouts require tmux #{feature.since}"
|
|
425
|
+
puts "Refusal: #{feature.error}"
|
|
426
|
+
end
|
|
427
|
+
```
|
|
428
|
+
<!-- /example -->
|
|
429
|
+
|
|
430
|
+
```text
|
|
431
|
+
JSON layouts require tmux 3.8
|
|
432
|
+
Refusal: LibTmux::UnsupportedFeatureError
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
More: [Support queries, workarounds and snapshot limits][behavior-capabilities].
|
|
436
|
+
|
|
437
|
+
### [`Pane#wait_for_text`][pane-wait_for_text]: wait for a program reply
|
|
438
|
+
|
|
439
|
+
Choose a reply that differs from the input. tmux can echo what you type.
|
|
440
|
+
|
|
441
|
+
<!-- example: api_text_wait/main -->
|
|
442
|
+
```ruby
|
|
443
|
+
require "libtmux"
|
|
444
|
+
|
|
445
|
+
program = <<~'RUBY'
|
|
446
|
+
STDOUT.sync = true
|
|
447
|
+
puts "Reply from the fixture" if gets&.chomp == "green"
|
|
448
|
+
STDIN.read
|
|
449
|
+
RUBY
|
|
450
|
+
|
|
451
|
+
LibTmux::Server.start do |server|
|
|
452
|
+
pane = server.new_session(name: "reply", command: [Gem.ruby, "-e", program],
|
|
453
|
+
receipt: true).pane
|
|
454
|
+
pane.send_text("green")
|
|
455
|
+
pane.send_keys("Enter")
|
|
456
|
+
|
|
457
|
+
reply = "Reply from the fixture"
|
|
458
|
+
result = pane.wait_for_text(reply)
|
|
459
|
+
puts result.text.lines(chomp: true).map(&:rstrip).find { |line| line == reply }
|
|
460
|
+
end
|
|
461
|
+
```
|
|
462
|
+
<!-- /example -->
|
|
463
|
+
|
|
464
|
+
It prints `Reply from the fixture`. The wait searches the visible screen and
|
|
465
|
+
includes output printed by the native `after-capture-pane` hook.
|
|
466
|
+
|
|
467
|
+
More: [Pane text waits][behavior-text-waits].
|
|
468
|
+
|
|
309
469
|
## Use the tmux server you already run
|
|
310
470
|
|
|
311
471
|
### [`Server.new`][server-new]: borrow a daemon
|
|
@@ -369,7 +529,8 @@ LibTmux::Server.start do |server|
|
|
|
369
529
|
server.new_session(name: "work", command: ["/bin/cat"])
|
|
370
530
|
cancellation = LibTmux::Cancellation.new
|
|
371
531
|
waiting = Thread.new do
|
|
372
|
-
server.run(["wait-for", "-S", "ready", ";", "wait-for", "held"],
|
|
532
|
+
server.run(["wait-for", "-S", "ready", ";", "wait-for", "held"],
|
|
533
|
+
timeout: 5, cancel: cancellation)
|
|
373
534
|
rescue LibTmux::Cancelled => error
|
|
374
535
|
error
|
|
375
536
|
end
|
|
@@ -378,7 +539,13 @@ LibTmux::Server.start do |server|
|
|
|
378
539
|
failure = waiting.value
|
|
379
540
|
puts "request: #{failure.class}"
|
|
380
541
|
puts "delivery: #{failure.delivery}"
|
|
381
|
-
|
|
542
|
+
ensure
|
|
543
|
+
begin
|
|
544
|
+
cancellation&.cancel
|
|
545
|
+
waiting&.join
|
|
546
|
+
ensure
|
|
547
|
+
cancellation&.close
|
|
548
|
+
end
|
|
382
549
|
end
|
|
383
550
|
```
|
|
384
551
|
<!-- /example -->
|
|
@@ -430,11 +597,9 @@ windows: @0
|
|
|
430
597
|
```
|
|
431
598
|
|
|
432
599
|
- Select, unlink, move, swap and display check the whole link identity in the
|
|
433
|
-
same tmux queue turn as the operation
|
|
434
|
-
- A hook that waits before dispatch cannot turn a stale link into its
|
|
600
|
+
same tmux queue turn as the operation, so a stale link never becomes its
|
|
435
601
|
replacement.
|
|
436
|
-
- Rewriting command aliases during an operation is outside that guarantee
|
|
437
|
-
coordinate configuration changes.
|
|
602
|
+
- Rewriting command aliases during an operation is outside that guarantee.
|
|
438
603
|
|
|
439
604
|
The contract is in [Window links][behavior-window-links], and the
|
|
440
605
|
[linked-windows recipe](../../docs/recipes.md#one-window-at-three-indexes)
|
|
@@ -484,6 +649,8 @@ hook: display-message created
|
|
|
484
649
|
|
|
485
650
|
The contracts are in [Options and hooks][behavior-options] and
|
|
486
651
|
[Option values][behavior-option-values].
|
|
652
|
+
Look up built-in types, choices and hook scopes in the
|
|
653
|
+
[option catalog][behavior-option-catalog].
|
|
487
654
|
|
|
488
655
|
## Watch tmux change
|
|
489
656
|
|
|
@@ -507,7 +674,10 @@ LibTmux::Server.start do |server|
|
|
|
507
674
|
puts "reply: #{reply.blocks.last.body.strip}"
|
|
508
675
|
events = control.subscribe(max_events: 64, max_bytes: 65_536)
|
|
509
676
|
window.rename("renamed")
|
|
510
|
-
event =
|
|
677
|
+
event = nil
|
|
678
|
+
until event&.raw&.start_with?("%window-renamed")
|
|
679
|
+
event = events.next(timeout: 5)
|
|
680
|
+
end
|
|
511
681
|
puts "event: #{event.raw.strip}"
|
|
512
682
|
end
|
|
513
683
|
end
|
|
@@ -612,22 +782,37 @@ application owns. Require `libtmux/async`, then open a scope with
|
|
|
612
782
|
$ gem install libtmux-async
|
|
613
783
|
```
|
|
614
784
|
|
|
615
|
-
Capture every pane concurrently with [`Scope#map`][async-scope-map]
|
|
616
|
-
excerpt uses an open [`LibTmux::Server`][server] and the `Example.check`
|
|
617
|
-
assertion helper from the [complete program](../../examples/async_cancel.rb):
|
|
785
|
+
Capture every pane concurrently with [`Scope#map`][async-scope-map]:
|
|
618
786
|
|
|
619
|
-
<!-- example:
|
|
787
|
+
<!-- example: api_async_scope/main -->
|
|
620
788
|
```ruby
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
789
|
+
require "libtmux"
|
|
790
|
+
require "libtmux/async"
|
|
791
|
+
|
|
792
|
+
LibTmux::Server.start do |server|
|
|
793
|
+
server.new_session(name: "work", command: ["/bin/cat"])
|
|
794
|
+
server.new_session(name: "logs", command: ["/bin/cat"])
|
|
795
|
+
Async do |parent|
|
|
796
|
+
LibTmux::Async.open(parent: parent, server: server) do |scope|
|
|
797
|
+
refs = scope.server.list_panes.map(&:ref)
|
|
798
|
+
screens = scope.map(refs, concurrency: 2) do |ref|
|
|
799
|
+
scope.server.pane(ref).capture
|
|
800
|
+
end
|
|
801
|
+
puts "captured panes: #{screens.length}"
|
|
802
|
+
puts "all succeeded: #{screens.all?(&:success?)}"
|
|
803
|
+
end
|
|
804
|
+
end.wait
|
|
805
|
+
end
|
|
628
806
|
```
|
|
629
807
|
<!-- /example -->
|
|
630
808
|
|
|
809
|
+
It prints:
|
|
810
|
+
|
|
811
|
+
```text
|
|
812
|
+
captured panes: 2
|
|
813
|
+
all succeeded: true
|
|
814
|
+
```
|
|
815
|
+
|
|
631
816
|
### [libtmux-mcp](https://github.com/libtmux/libtmux-ruby/tree/master/gems/libtmux-mcp): a tmux server for MCP clients
|
|
632
817
|
|
|
633
818
|
An MCP server over stdio for one tmux server, with an explicit tool policy.
|
|
@@ -643,19 +828,17 @@ Installs `libtmux-mcp`; require `libtmux/mcp` to embed it through
|
|
|
643
828
|
$ gem install libtmux-mcp
|
|
644
829
|
```
|
|
645
830
|
|
|
646
|
-
|
|
647
|
-
socket
|
|
648
|
-
|
|
649
|
-
```console
|
|
650
|
-
$ tmux -L agent new-session -d -s work
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
Add the server to Claude Code. Until you enable more tools, it serves
|
|
831
|
+
Add the server to Claude Code. `--start-session work` starts a tmux server on
|
|
832
|
+
the socket `agent` when none answers there, with a session named `work`, and
|
|
833
|
+
stops it when the server exits. Until you enable more tools, the server serves
|
|
654
834
|
[`tmux_capabilities`][tool-tmux_capabilities] and
|
|
655
835
|
[`tmux_snapshot`][tool-tmux_snapshot]:
|
|
656
836
|
|
|
657
837
|
```console
|
|
658
|
-
$ claude mcp add tmux -- libtmux-mcp
|
|
838
|
+
$ claude mcp add tmux -- libtmux-mcp \
|
|
839
|
+
--socket-name agent \
|
|
840
|
+
--start-session work \
|
|
841
|
+
--endpoint dev
|
|
659
842
|
```
|
|
660
843
|
|
|
661
844
|
The [MCP README](../libtmux-mcp/README.md) covers other clients, every tool and
|
|
@@ -714,48 +897,36 @@ server and lists every option.
|
|
|
714
897
|
[Live handles][behavior-live-handles].
|
|
715
898
|
- **A terminal emulator.** [`Pane#capture`][pane-capture] returns the bytes
|
|
716
899
|
tmux holds for the screen, with the flags above to shape them.
|
|
717
|
-
- **A server it starts
|
|
718
|
-
[`Server.open`][server-open] bind a running server
|
|
719
|
-
|
|
720
|
-
`
|
|
721
|
-
|
|
900
|
+
- **A server it starts unasked.** [`Server.new`][server-new] and
|
|
901
|
+
[`Server.open`][server-open] bind a running server; only
|
|
902
|
+
[`Server.start`][server-start] starts one. With no socket named,
|
|
903
|
+
[`Endpoint.new`][endpoint-new] picks the socket tmux would, so a program run
|
|
904
|
+
inside tmux reaches that tmux.
|
|
722
905
|
- **Replay.** A reconnected control connection reports a gap and never replays
|
|
723
906
|
requests or missed output. See [Control flow][behavior-control-flow].
|
|
724
907
|
- **Transactions.** A [group][server-run_group] runs in order and keeps the
|
|
725
908
|
effects of the steps before a failure.
|
|
726
|
-
- **Whole-program typing.** RBS declarations ship with the gem
|
|
727
|
-
|
|
909
|
+
- **Whole-program typing.** RBS declarations ship with the gem. See
|
|
910
|
+
[Signature proof][behavior-signature].
|
|
728
911
|
|
|
729
912
|
## Support and status
|
|
730
913
|
|
|
731
|
-
Releases are numbered `0.1.N`, and
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
`fiddle` and `io-console`.
|
|
740
|
-
- **tmux 3.3a or newer.** Unpatched 3.3 is below the minimum. A
|
|
741
|
-
[server handle][server] checks the connected daemon's release before it sends
|
|
742
|
-
the requested command, and refuses an older daemon even when its client is
|
|
743
|
-
newer.
|
|
914
|
+
- **Unstable API.** Releases are numbered `0.1.N`, and any release may change
|
|
915
|
+
or remove exported identifiers. Pin an exact version. See the
|
|
916
|
+
[changelog](CHANGELOG.md), and the [main
|
|
917
|
+
changelog](https://github.com/libtmux/libtmux-ruby/blob/master/CHANGELOG.md)
|
|
918
|
+
for changes that span gems.
|
|
919
|
+
- **Ruby 3.3 or newer** and **tmux 3.3a or newer.** A [server handle][server]
|
|
920
|
+
checks the connected daemon's release before it runs a command, and refuses
|
|
921
|
+
an older daemon even when its client is newer.
|
|
744
922
|
- **Control connections need tmux 3.7 or newer.** An older daemon refuses
|
|
745
923
|
[`open_control`][server-open_control] before a control client attaches.
|
|
746
924
|
Subprocess operations and snapshots do not need it. The
|
|
747
925
|
[optional feature table](../../docs/reference/behavior.md#optional-tmux-features)
|
|
748
|
-
lists the other
|
|
749
|
-
- **Linux, including WSL, and macOS.**
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
and a release runs all of them. macOS is supported on a best-effort basis, and CI coverage for it is highly
|
|
753
|
-
limited.
|
|
754
|
-
- **tmux master and old daemons.** On Ubuntu a release also runs the suite
|
|
755
|
-
against a pinned tmux master, and checks that tmux 3.0a, 3.1c, 3.2a and 3.3
|
|
756
|
-
daemons are refused.
|
|
757
|
-
- **Per-revision results.** Read the workflow's results for your revision
|
|
758
|
-
before relying on one combination.
|
|
926
|
+
lists the other releases.
|
|
927
|
+
- **Linux, including WSL, and macOS.** CI runs on Linux; macOS is best effort.
|
|
928
|
+
See the [compatibility workflow][compat] and the
|
|
929
|
+
[CI matrix](../../.github/CONTRIBUTING.md#running-ci-against-any-tmux).
|
|
759
930
|
|
|
760
931
|
## Documentation
|
|
761
932
|
|
|
@@ -763,7 +934,7 @@ for changes that span gems.
|
|
|
763
934
|
| --- | --- |
|
|
764
935
|
| [Reference](https://libtmux.org/en/ruby/latest/reference/) | Every public class and method, one page each |
|
|
765
936
|
| [Guides](https://libtmux.org/en/ruby/latest/guides/) | Getting started, server bindings and the Async scope |
|
|
766
|
-
| [Recipes](../../docs/recipes.md) | Complete programs
|
|
937
|
+
| [Recipes](../../docs/recipes.md) | Complete programs and their excerpts |
|
|
767
938
|
| [Execution modes](../../docs/modes.md) | Blocking calls, Async tasks and control subscriptions |
|
|
768
939
|
| [Ownership and errors](../../docs/ownership-errors.md) | What close and failure mean |
|
|
769
940
|
| [Public behavior](../../docs/reference/behavior.md) | Defaults, ownership, blocking and failure of each call |
|
|
@@ -777,12 +948,14 @@ MIT. See [LICENSE](LICENSE).
|
|
|
777
948
|
[async-scope-map]: https://libtmux.org/en/ruby/latest/reference/libtmux-async-scope-map/
|
|
778
949
|
[behavior-cancellation]: ../../docs/reference/behavior.md#cancellation-tokens
|
|
779
950
|
[behavior-capture]: ../../docs/reference/behavior.md#pane-input-and-capture
|
|
951
|
+
[behavior-text-waits]: ../../docs/reference/behavior.md#pane-text-waits
|
|
780
952
|
[behavior-control]: ../../docs/reference/behavior.md#control-connections
|
|
781
953
|
[behavior-control-flow]: ../../docs/reference/behavior.md#control-flow
|
|
782
954
|
[behavior-creation]: ../../docs/reference/behavior.md#creation
|
|
783
955
|
[behavior-live-handles]: ../../docs/reference/behavior.md#live-handles
|
|
784
956
|
[behavior-option-values]: ../../docs/reference/behavior.md#option-values
|
|
785
957
|
[behavior-options]: ../../docs/reference/behavior.md#options-and-hooks
|
|
958
|
+
[behavior-option-catalog]: ../../docs/reference/behavior.md#option-catalog
|
|
786
959
|
[behavior-records]: ../../docs/reference/behavior.md#captured-records
|
|
787
960
|
[behavior-signature]: ../../docs/reference/behavior.md#signature-proof
|
|
788
961
|
[behavior-window-links]: ../../docs/reference/behavior.md#window-links
|
|
@@ -814,6 +987,7 @@ MIT. See [LICENSE](LICENSE).
|
|
|
814
987
|
[optionvalue-as]: https://libtmux.org/en/ruby/latest/reference/libtmux-optionvalue-as/
|
|
815
988
|
[pane]: https://libtmux.org/en/ruby/latest/reference/libtmux-pane-14z6/
|
|
816
989
|
[pane-capture]: https://libtmux.org/en/ruby/latest/reference/libtmux-pane-capture/
|
|
990
|
+
[pane-wait_for_text]: https://libtmux.org/en/ruby/latest/reference/libtmux-pane-wait_for_text/
|
|
817
991
|
[pane-send_keys]: https://libtmux.org/en/ruby/latest/reference/libtmux-pane-send_keys/
|
|
818
992
|
[pane-send_text]: https://libtmux.org/en/ruby/latest/reference/libtmux-pane-send_text/
|
|
819
993
|
[pane-split]: https://libtmux.org/en/ruby/latest/reference/libtmux-pane-split/
|
|
@@ -852,3 +1026,6 @@ MIT. See [LICENSE](LICENSE).
|
|
|
852
1026
|
[window-split]: https://libtmux.org/en/ruby/latest/reference/libtmux-window-split/
|
|
853
1027
|
[windowlink]: https://libtmux.org/en/ruby/latest/reference/libtmux-windowlink-tusj/
|
|
854
1028
|
[workspace]: https://libtmux.org/en/ruby/latest/workspace/reference/libtmux-workspace/
|
|
1029
|
+
|
|
1030
|
+
[server-capabilities]: https://libtmux.org/en/ruby/latest/reference/libtmux-server-capabilities/
|
|
1031
|
+
[behavior-capabilities]: ../../docs/reference/behavior.md#daemon-capabilities
|