# LibTmux\Rename-TmuxSession

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/bbab29e574920cd100e4b80688185d91c5d7f877/src/LibTmux.PowerShell/RenameTmuxSessionCommand.cs#L7
- **Page:** https://libtmux.org/en/powershell/latest/reference/libtmux-rename-tmuxsession/

```
Rename-TmuxSession
    [-Session] <LibTmux.Session>
    [-Name] <System.String>
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
```

Rename a native session and optionally emit its replacement.

Rename the supplied native [`LibTmux.Session`](/en/csharp/latest/reference/libtmux-session/). The endpoint and daemon generation come
from that handle, so the session is named by its ID and not by its old name.
Only that session changes.

With PassThru, return a new [`Session`](/en/csharp/latest/reference/libtmux-session/) handle that carries the new name. The original
handle keeps the name it captured and is stale after the rename. Without
PassThru, emit no success object. tmux expands the name as a format, so a
number sign in it does not survive verbatim. [`WhatIf`](/en/powershell/latest/reference/libtmux-rename-tmuxsession/#LibTmux%5CRename-TmuxSession.parameter.WhatIf) performs no tmux I/O.

### Notes

Failures use [`Tmux.SessionRenameFailed`](https://github.com/libtmux/libtmux-powershell/blob/bbab29e574920cd100e4b80688185d91c5d7f877/docs/reference/LibTmux/Rename-TmuxSession.md#notes) and retain the original core exception, its
dispatch information and the failed owner. [`ErrorAction`](/en/powershell/latest/reference/libtmux-rename-tmuxsession/#LibTmux%5CRename-TmuxSession.parameter.ErrorAction) Continue permits later
owners to be processed; [`ErrorAction`](/en/powershell/latest/reference/libtmux-rename-tmuxsession/#LibTmux%5CRename-TmuxSession.parameter.ErrorAction) Stop stops on the first failure. A missing
target remains an error. No mutation is retried.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Confirmation:** Supports `-WhatIf` and `-Confirm`; confirm impact: Medium.
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Session`: A native LibTmux.Session selected from an explicit endpoint.
- **Outputs:** `LibTmux.Session`

Related APIs:

- [Create sessions, windows and panes](https://github.com/libtmux/libtmux-powershell/blob/bbab29e574920cd100e4b80688185d91c5d7f877/docs/create.md)
- [Choose endpoints and owners](https://github.com/libtmux/libtmux-powershell/blob/bbab29e574920cd100e4b80688185d91c5d7f877/docs/read.md)

## Parameters

- `Session` (`LibTmux.Session`): The native session to rename. Select it with Get-TmuxSession on the endpoint you intend to change.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Name` (`System.String`): The new session name. An empty name is rejected before tmux is called.
  Required. Position 1. Does not accept pipeline input. [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0).
- `PassThru` (`System.Management.Automation.SwitchParameter`): Emit a new Session handle that carries the new name, read back after the rename.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input.
- `Verbose` (`System.Management.Automation.SwitchParameter`): Display verbose messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `vb`.
- `Debug` (`System.Management.Automation.SwitchParameter`): Display debug messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `db`.
- `ErrorAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to non-terminating errors.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ea`.
- `WarningAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to warning messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wa`.
- `InformationAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles information messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `infa`.
- `ProgressAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles progress updates.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `proga`.
- `ErrorVariable` (`System.String`): Store the command's error records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ev`.
- `WarningVariable` (`System.String`): Store the command's warning records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wv`.
- `InformationVariable` (`System.String`): Store the command's information records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `iv`.
- `OutVariable` (`System.String`): Save output in the named variable while passing it down the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ov`.
- `OutBuffer` (`System.Int32`): Buffer output before passing it to the next pipeline command.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ob`.
- `PipelineVariable` (`System.String`): Make the most recent output object available through a named variable within the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `pv`.
- `WhatIf` (`System.Management.Automation.SwitchParameter`): Runs the command in a mode that only reports what would happen without performing the actions.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `wi`.
- `Confirm` (`System.Management.Automation.SwitchParameter`): Prompts you for confirmation before running the cmdlet.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `cf`.

## Returns

`LibTmux.Session`: With PassThru, one replacement handle for each input. Otherwise no success
objects are emitted.

## Examples

Example 1

Rename the previously selected $session and emit the replacement handle. Assign
the output for subsequent operations.

[Source example](https://github.com/libtmux/libtmux-powershell/blob/bbab29e574920cd100e4b80688185d91c5d7f877/docs/reference/LibTmux/Rename-TmuxSession.md).

```powershell
$session | LibTmux\Rename-TmuxSession -Name release -PassThru
```

## Guides

Pages that discuss `Rename-TmuxSession`.

- [Create sessions, windows and panes](/en/powershell/latest/guides/create/)
