# LibTmux::Server.start

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Ruby
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ruby/blob/da7b6191b9439e3c84fa1c9eeaa9168263ee7af4/gems/libtmux/lib/libtmux/owned.rb#L12
- **Page:** https://libtmux.org/en/ruby/v0.1.1/reference/libtmux-server-start/

```
def self.start: (
  ?executable: ::String,
  ?config: ::String?,
  ?timeout: ::Numeric,
  ?cancel: untyped,
  **untyped
) -> ::LibTmux::Server

def self.start: [T] (
  ?executable: ::String,
  ?config: ::String?,
  ?timeout: ::Numeric,
  ?cancel: untyped,
  **untyped
) {
  (::LibTmux::Server) -> T
} -> T
```

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

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`:

```ruby
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.

[Source example](https://github.com/libtmux/libtmux-ruby/blob/da7b6191b9439e3c84fa1c9eeaa9168263ee7af4/examples/api/new_session.rb).

```ruby
# 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:

```console
$ bundle install && \
  bundle exec ruby new_session.rb
```

Expected output:

```text
session: $0
window: @0
pane: %0
```

## Type parameters

- `T` (for `start(executable, config, timeout, cancel, kwargs) [overload 2]`)

## Parameters

- `executable` (`::String`)
- `config` (`::String?`)
- `timeout` (`::Numeric`)
- `cancel` (`untyped`)
- `kwargs` (`untyped`)

## Guides

Pages that discuss `start`.

- [Capture pane output](/en/ruby/v0.1.1/examples/capture-pane-output/)
