Core Library0.xAPI Reference

Choose documentation 3

v0.1.1

Current version

v0.1.1
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-ruby v0.1.1

Server.run

Raw tmux arguments retain tmux's separators and format semantics.

Source and package
Qualified name
LibTmux::Server#run
Module
LibTmux
Declared in
Server
Package
libtmux
Source
gems/libtmux/lib/libtmux/server.rb
Other languages
PowerShell Julia Elixirfunction PythonLuaTypeScriptRustGoJavaC#C++ Swift Kotlin Scala F#
def run: ( ::Array[::String], ?input: ::String, ?timeout: ::Numeric, ?cancel: untyped ) -> ::LibTmux::CommandResult

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/cat and /bin/sh available. In an empty directory, save this Gemfile:

source "https://rubygems.org"
gem "libtmux", "0.1.1"

Save this complete program as cancellation.rb. Its Server.start() block owns a private tmux server and stops it on exit, including after an error. View source

# frozen_string_literal: true
begin
# docs:begin main
require "libtmux"
LibTmux::Server.start do |server|
server.new_session(name: "work", command: ["/bin/cat"])
cancellation = LibTmux::Cancellation.new
waiting = Thread.new do
server.run(["wait-for", "-S", "ready", ";", "wait-for", "held"], timeout: 5, cancel: cancellation)
rescue LibTmux::Cancelled => error
error
end
server.wait_for("ready", timeout: 5)
cancellation.cancel
failure = waiting.value
puts "request: #{failure.class}"
puts "delivery: #{failure.delivery}"
cancellation.close
end
# docs:end main
rescue StandardError => error
warn "#{error.class}: #{error.message}"
exit 1
end

Install the gem and run the program. An operation or cleanup error makes it exit unsuccessfully:

Terminal window
$ bundle install && \
bundle exec ruby cancellation.rb

Expected output:

request: LibTmux::Cancelled
delivery: possibly_sent
Parameters

In other ports#

Run a shell command through tmux

Equivalents of Run a shell command through tmux in other languages
Language Equivalent
Python libtmux.Server.run_shell
TypeScript server.Server.runShell
Rust server.Server.run_shell
Go tmux.Server.RunShell
Java io.github.libtmux.Shell.run
C# LibTmux.Server.RunShellAsync
C++ libtmux::Server::run_shell
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

Equivalents of Run a tmux command this port does not model in other languages
Language Equivalent
Python libtmux.Server.cmd
Lua libtmux.Server:command
Elixir LibTmux.Server.run/3 Runs one trusted Command without attaching a client and returns bounded output with exit evidence.
TypeScript server.Server.cmd
Rust server.Server.cmd
Go tmux.Server.Cmd
Java io.github.libtmux.Server.cmd
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#.

Esc

Type to search.

Reference previewOpen reference