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 ) -> ::Lib
Tmux:: def self.start: [T] ( ?executable: ::String, ?config: ::String?, ?timeout: ::Numeric, ?cancel: untyped, **untyped ) { (::LibServer Tmux:: ) -> T } -> TServer -
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/catand/bin/shavailable. In an empty directory, save thisGemfile:source "https://rubygems.org"gem "libtmux", "0.1.1"Save this complete program as
new_session.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|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 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 new_session.rbExpected output:
session: $0window: @0pane: %0
Guides#
Pages that discuss start.