# LibTmux.switch_client

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

```
switch_client(
    connection::LibTmux.ControlConnection,
    client::LibTmux.ClientRef,
    session::LibTmux.SessionRef;
    update_environment,
    kwargs...
)

switch_client(
    server::LibTmux.Server,
    client::LibTmux.ClientRef,
    session::LibTmux.SessionRef;
    update_environment,
    kwargs...
)
```

## Methods

### `switch_client` (overload 1)

```julia
switch_client(
    connection::LibTmux.ControlConnection,
    client::LibTmux.ClientRef,
    session::LibTmux.SessionRef;
    update_environment,
    kwargs...
)
```

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

Switch the captured client to the exact session on the connected daemon. Recheck its name and observed PID/creation-time incarnation before submission. Client names must be valid UTF-8 without spaces or control bytes because tmux reflects them as unescaped notification fields. `update_environment=true` copies the client's configured environment variables into the destination session.

```julia
switch_client(connection::ControlConnection, client::ClientRef, session::SessionRef;
              update_environment=false, kwargs...)
```



Return `ControlResult` after the completion fence. The connection pins daemon identity; client incarnation remains observational and can change between the check and mutation. `strict=false` does not weaken the daemon guard. There is no implicit current client, replay or subprocess fallback.

### `switch_client` (overload 2)

```julia
switch_client(
    server::LibTmux.Server,
    client::LibTmux.ClientRef,
    session::LibTmux.SessionRef;
    update_environment,
    kwargs...
)
```

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

Switch exactly the captured client to a session. Recheck its name and observed PID/creation-time incarnation before submission. `update_environment=true` also updates the destination session's environment from the client. Incarnation and generation checks are best effort; strict execution is unsupported.

```julia
switch_client(server, client::ClientRef, session::SessionRef;
              update_environment=false, kwargs...)
```

## Parameters

- `connection` (`LibTmux.ControlConnection`) (for `switch_client(connection, client, session, update_environment, kwargs)`)
- `client` (`LibTmux.ClientRef`)
- `session` (`LibTmux.SessionRef`)
- `update_environment` (`Bool`)
  Default: `false`.
- `kwargs`
- `server` (`LibTmux.Server`) (for `switch_client(server, client, session, update_environment, kwargs)`)
