Remove sessions, windows and panes
Needs libtmux for PowerShell 0.x Install
Remove-TmuxSession, Remove-TmuxWindow and Remove-TmuxPane take handles
directly or from the pipeline. Each removes its target and emits nothing on
success. Choose the target with the explicit endpoint and read commands.
Removal has high confirmation impact, so the default preference prompts. Check
the endpoint and ID in the prompt, and use -Confirm:$false when an unattended
caller has already chosen the target. -WhatIf describes the removal without
contacting tmux:
$session | Remove-TmuxSession -WhatIfRemove an owned session after its work finishes:
$session | Remove-TmuxSession -Confirm:$false- An empty pipeline does nothing, and several targets are processed in input order.
- Success emits no handles, Booleans or task objects, so
@($pane | Remove-TmuxPane -Confirm:$false)is empty. - An old handle keeps its captured fields as an observation of the removed object.
Linked windows and cascading removal
Removing a window destroys the physical window, every pane in it, and all its links in every session. It does not merely unlink the placement through which the window was selected. Repeated placements of that physical window are removed together:
$window | Remove-TmuxWindow -Confirm:$falseTo remove one session placement while preserving other links, use Remove-TmuxWindowLink.
- Removing a session destroys windows linked nowhere else. A window still linked to another session survives with its panes.
- Removing the last pane destroys its window. Removing a session’s last window removes the session, and tmux may exit when no sessions remain.
- None of this gives the module ownership of the daemon or cleans up other resources.
$pane | Remove-TmuxPane -Confirm:$falseStop a server
Stop-TmuxServer stops the whole server
that a LibTmux.Server handle names, with kill-server: every session, window
and pane on it ends. Use it to finish with a private server you started, such as
one New-TmuxServer named with a socket
of its own, instead of removing its sessions one by one.
It follows the same rules as the removals above: high confirmation impact, no
success object, -WhatIf contacts nothing, and an empty pipeline does nothing.
A server that is already gone counts as stopped, so it is not an error. The
other error rules below apply with the ID Tmux.ServerStopFailed.
Errors and cancellation
- Error IDs:
Tmux.SessionRemoveFailed,Tmux.WindowRemoveFailedandTmux.PaneRemoveFailed. The error record keeps the native owner, the original core exception and its dispatch metadata. - Missing target: an error.
-ErrorAction Continuelets later targets run, and-ErrorAction Stopstops before the next one. - Stale handles: a handle belongs to one endpoint and daemon generation. After the daemon is replaced, the core rejects an old handle instead of resolving its numeric ID against the replacement.
- Retries and cancellation: removal is never retried. Stopping the pipeline cancels the active client operation; a removal tmux already accepted is not rolled back.