# LibTmux::Async::Server#new_session

- **Module:** LibTmux::Async
- **Package:** libtmux-async
- **Language:** Ruby
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ruby/blob/da7b6191b9439e3c84fa1c9eeaa9168263ee7af4/gems/libtmux/lib/libtmux/server.rb#L252
- **Public owner:** LibTmux::Server#new_session
- **Page:** https://libtmux.org/en/ruby/v0.1.1/reference/libtmux-async-server-new_session/

```
def new_session: (
  name: ::String,
  command: ::Array[::String],
  receipt: true,
  ?width: ::Integer?,
  ?height: ::Integer?,
  ?window_name: ::String?,
  ?cwd: ::String?,
  ?environment: ::Hash[::String, ::String],
  ?timeout: ::Numeric,
  ?cancel: untyped
) -> ::LibTmux::CreationReceipt

def new_session: (
  name: ::String,
  command: ::Array[::String],
  ?receipt: false,
  ?width: ::Integer?,
  ?height: ::Integer?,
  ?window_name: ::String?,
  ?cwd: ::String?,
  ?environment: ::Hash[::String, ::String],
  ?timeout: ::Numeric,
  ?cancel: untyped
) -> ::LibTmux::Session
```

Behavior: Creation.

Behavior contract: Creation.

## Parameters

- `name` (`::String`)
- `command` (`::Array[::String]`)
- `receipt` (`true`) (for `new_session(name, command, receipt, width, height, window_name, cwd, environment, timeout, cancel) [overload 1]`)
- `width` (`::Integer?`)
- `height` (`::Integer?`)
- `window_name` (`::String?`)
- `cwd` (`::String?`)
- `environment` (`::Hash[::String, ::String]`)
- `timeout` (`::Numeric`)
- `cancel` (`untyped`)
- `receipt` (`false`) (for `new_session(name, command, receipt, width, height, window_name, cwd, environment, timeout, cancel) [overload 2]`)

## tmux command

The tmux commands behind `new_session`.

- [`new-session`](/en/tmux/latest/manual/new-session/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_new_session_entry`](/en/tmux/latest/reference/c-variable-cmd_new_session_entry/) (attribute)
- [`cmd_new_session_exec`](/en/tmux/latest/reference/c-function-cmd-new-session-c-cmd_new_session_exec/) (function)

Each path starts at a function a command runs, which is degree 1. The degree counts steps from there along the path, and each step is a call or a reference: degree 2 is reached from that function, degree 3 from the next, and so on.

### Create a session and its first pane

1. [`cmd_new_session_exec`](/en/tmux/latest/reference/c-function-cmd-new-session-c-cmd_new_session_exec/) (function)
2. calls → [`spawn_window`](/en/tmux/latest/reference/c-function-spawn_window/) (function)
3. calls → [`spawn_pane`](/en/tmux/latest/reference/c-function-spawn_pane/) (function)
4. calls → [`window_add_pane`](/en/tmux/latest/reference/c-function-window_add_pane/) (function)
5. calls → [`window_pane_create`](/en/tmux/latest/reference/c-function-window-c-window_pane_create/) (function)
