# libtmux:new-session

- **Package:** libtmux
- **Language:** Common Lisp
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-lisp/blob/c2e5fc4ed3befda21f45dfa5d5868c38fd138311/src/creation.lisp#L64
- **Public owner:** libtmux
- **Page:** https://libtmux.org/en/lisp/latest/reference/libtmux-new-session/

```
(new-session client &key name window-name width height cwd environment (command nil command-p) (shell-command nil shell-command-p) cancel-token timeout output-limit)
```

Create a detached session on the selected live daemon; return a COMMAND-OUTCOME.
NAME, WINDOW-NAME and CWD are literal. WIDTH/HEIGHT are positive initial cell
dimensions through 65535. ENVIRONMENT, COMMAND and SHELL-COMMAND follow
NEW-WINDOW. OUTCOME-VALUE supplies the created session; acquisition failure is
retained separately. This operation requires an existing daemon and never
silently starts or replaces one. A separate bootstrap path remains in development.

## Parameters

- `client`
- `name?`
- `window-name?`
- `width?`
- `height?`
- `cwd?`
- `environment?`
- `command?`
- `shell-command?`
- `cancel-token?`
- `timeout?`
- `output-limit?`

## 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)

## Guides

Pages that discuss `new-session`.

### Examples

- [Capture pane output](/en/lisp/latest/examples/capture-pane-output/)

### Guides

- [Attaching to tmux](/en/lisp/latest/guides/attaching-to-tmux/)
- [Explicit operations](/en/lisp/latest/guides/operations/)
