# LibTmux.new_window

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** Julia
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/src/operations.jl#L195
- **Page:** https://libtmux.org/en/julia/latest/reference/libtmux-new_window/

```
new_window(
    connection::LibTmux.ControlConnection,
    target::LibTmux.SessionRef;
    name,
    command,
    shell_command,
    start_directory,
    environment,
    index,
    kwargs...
)

new_window(
    server::LibTmux.Server,
    target::LibTmux.SessionRef;
    name,
    command,
    shell_command,
    start_directory,
    environment,
    index,
    kwargs...
)
```

## Methods

### `new_window` (overload 1)

```julia
new_window(
    connection::LibTmux.ControlConnection,
    target::LibTmux.SessionRef;
    name,
    command,
    shell_command,
    start_directory,
    environment,
    index,
    kwargs...
)
```

[Source](https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/src/control_operations.jl#L79).

Create a detached window through the existing connection and return its strict `WindowRef`. Options match the subprocess method. Names must be valid UTF-8 without control bytes because supported tmux versions can emit initial names unescaped in control notifications. This restriction is checked before writing. Command argv, environment values and directories retain their literal bytes; format metacharacters in names/directories are escaped separately.

```julia
new_window(connection::ControlConnection, session::SessionRef; kwargs...)
```



The same-queue fence proves command completion under the connection's trusted alias/hook contract. Cancellation can leave a created object; there is no replay, implicit destruction or transport fallback. Invalid creation replies raise `CreationResponseError` retaining the actual `ControlResult`. `strict=false` does not weaken the connection's generation checks.

### `new_window` (overload 2)

```julia
new_window(
    server::LibTmux.Server,
    target::LibTmux.SessionRef;
    name,
    command,
    shell_command,
    start_directory,
    environment,
    index,
    kwargs...
)
```

[Source](https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/src/operations.jl#L205).

Create a detached window in the target session and return its `WindowRef`. An explicit nonnegative `index` targets that session slot and refuses collisions. Omit it to use tmux's next available index. Command, directory, environment, deadline and strictness options follow [`new_session`](/en/julia/latest/reference/libtmux-new_session/). Identity checks are best effort. A changed identity in the creation reply raises `CreationResponseError`; the library does not retry or clean up.

```julia
new_window(server, target::SessionRef; name=nothing, index=nothing, kwargs...)
```

## Parameters

- `connection` (`LibTmux.ControlConnection`) (for `new_window(connection, target, name, command, shell_command, start_directory, environment, index, kwargs)`)
- `target` (`LibTmux.SessionRef`)
- `name`
  Default: `nothing`.
- `command`
  Default: `nothing`.
- `shell_command`
  Default: `nothing`.
- `start_directory`
  Default: `nothing`.
- `environment`
  Default: `()`.
- `index`
  Default: `nothing`.
- `kwargs`
- `server` (`LibTmux.Server`) (for `new_window(server, target, name, command, shell_command, start_directory, environment, index, kwargs)`)
