Server.run
Raw tmux arguments retain tmux's separators and format semantics.
Source and package
-
Description#
Behavior contract: Raw commands.
Examples#
Wake a blocked request from another thread with a cancellation token and read the delivery evidence on the Cancelled error. Use Ruby 3.3 or newer with Bundler, and tmux 3.3a or newer, on Unix with
/bin/catand/bin/shavailable. In an empty directory, save thisGemfile:source "https://rubygems.org"gem "libtmux", "0.1.1"Save this complete program as
cancellation.rb. ItsServer.start()block owns a private tmux server and stops it on exit, including after an error. View source# frozen_string_literal: truebegin# docs:begin mainrequire "libtmux"LibTmux::Server.start do |server|server.new_session(name: "work", command: ["/bin/cat"])cancellation = LibTmux::Cancellation.newwaiting = Thread.new doserver.run(["wait-for", "-S", "ready", ";", "wait-for", "held"], timeout: 5, cancel: cancellation)rescue LibTmux::Cancelled => errorerrorendserver.wait_for("ready", timeout: 5)cancellation.cancelfailure = waiting.valueputs "request: #{failure.class}"puts "delivery: #{failure.delivery}"cancellation.closeend# docs:end mainrescue StandardError => errorwarn "#{error.class}: #{error.message}"exit 1endInstall the gem and run the program. An operation or cleanup error makes it exit unsuccessfully:
Terminal window $ bundle install && \bundle exec ruby cancellation.rbExpected output:
request: LibTmux::Cancelleddelivery: possibly_sent
In other ports#
Run a shell command through tmux
| Language | Equivalent |
|---|---|
| Python | libtmux |
| TypeScript | server |
| Rust | server |
| Go | tmux |
| Java | io |
| C# | Lib |
| C++ | libtmux:: |
| Swift | Server.run(_:in:) types a command into a pane rather than running it on the host |
No equivalent is recorded in Lua, PowerShell, Julia, Elixir, Kotlin, Scala or F#.
Run a tmux command this port does not model
| Language | Equivalent |
|---|---|
| Python | libtmux |
| Lua | libtmux |
| Elixir | Lib Runs one trusted Command without attaching a client and returns bounded output with exit evidence. |
| TypeScript | server |
| Rust | server |
| Go | tmux |
| Java | io |
| C# | no equivalent on Server |
| C++ | no equivalent on Server |
| Swift | no equivalent on Server |
No equivalent is recorded in PowerShell, Julia, Kotlin, Scala or F#.