# LibTmux.Session.new_window/4

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/00d34b3d387da72a5a416f1dd3962a98c76cedd2/lib/libtmux/entities.ex#L130
- **Page:** https://libtmux.org/en/elixir/latest/reference/libtmux-session-new_window-4/

```
new_window(server, ref, name, options \\ [])
@spec new_window(
        LibTmux.Server.t(),
        LibTmux.Ref.t(),
        binary(),
        [LibTmux.Action.creation_option()]
      ) ::
        {:ok,
         LibTmux.Action.result(
           LibTmux.Action.creation_value()
         )}
        | {:error, LibTmux.Action.error()}
```

Creates a named detached window in an exact session through one-shot execution.

Returns `{:ok, result}` on completion, with `%{id: window_id, ref: nil}`
as its value. Capture a fresh observation for a bound reference. The session
reference is checked against the answering server before dispatch, with
the usual one-shot check/use race. Missing servers are not started.
Control connections are unsupported. tmux permits duplicate window names.

Names, `timeout`, `cwd` and explicit `command` forms follow
`LibTmux.Server.new_session/3`. The new window uses tmux's next available
index in this session. Existing observations remain unchanged.

    alias LibTmux.Session

    Session.new_window(server, session_ref, "logs", command: {:argv, ["/bin/cat"]})

## Parameters

- `server` (`LibTmux.Server.t()`)
- `ref` (`LibTmux.Ref.t()`)
- `name` (`binary()`)
- `options` (`[LibTmux.Action.creation_option()]`)
  Default: `[]`.
