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.start

Starts a foreground daemon on a new private endpoint. Close owns its exit. No session is created; the default config is empty. Startup blocks.

Source and package
Qualified name
LibTmux::Server.start
Module
LibTmux
Declared in
Server
Package
libtmux
Source
gems/libtmux/lib/libtmux/owned.rb
def self.start: ( ?executable: ::String, ?config: ::String?, ?timeout: ::Numeric, ?cancel: untyped, **untyped ) -> ::LibTmux::Serverdef self.start: [T] ( ?executable: ::String, ?config: ::String?, ?timeout: ::Numeric, ?cancel: untyped, **untyped ) { (::LibTmux::Server) -> T } -> T

Description#

Behavior contract: Owned daemons.

Examples#

Start a private server and create a session. Request a creation receipt to read the session, window, and pane IDs returned by that creation command. 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 new_session.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|
created = server.new_session(
name: "work", window_name: "main", command: ["/bin/cat"], receipt: true
)
puts "session: #{created.entity.id}"
puts "window: #{created.window.id}"
puts "pane: #{created.pane.id}"
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 new_session.rb

Expected output:

session: $0
window: @0
pane: %0
Type parameters
  • T # for start(executable, config, timeout, cancel, kwargs) [overload 2]

Parameters

Guides#

Pages that discuss start.

Esc

Type to search.

Reference previewOpen reference