# LibTmux\New-TmuxServer

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/06233d3c99b40a5bce966c9e1d358f346ff4de55/src/LibTmux.PowerShell/NewTmuxServerCommand.cs#L6
- **Page:** https://libtmux.org/en/powershell/latest/reference/libtmux-new-tmuxserver/

```
Name (default):
New-TmuxServer
    [-SocketName <System.String>]
    [-TmuxBinaryPath <System.String>]
    [-ConfigurationFile <System.String>]
    [<CommonParameters>]

Path:
New-TmuxServer
    -SocketPath <System.String>
    [-TmuxBinaryPath <System.String>]
    [-ConfigurationFile <System.String>]
    [<CommonParameters>]
```

Construct a tmux endpoint handle without contacting it.

Choose a socket name or absolute socket path. Construction performs no tmux I/O
and does not start or own a daemon. A later command explicitly acquires data or
changes tmux.

Omitting both socket parameters passes tmux no socket, so tmux picks the
server: the one the TMUX variable names inside a tmux pane, otherwise its
default socket. Two variables choose a socket for such a handle.
LIBTMUX_SOCKET_PATH becomes -S and LIBTMUX_SOCKET becomes -L; when both are set
the path wins, and a blank value counts as unset. A parameter beats both
variables. The handle reads the variables when it is made.
LIBTMUX_SOCKET_NAME, which earlier versions read, selects nothing.

**What is on here.** Most cmdlets in the module start from the handle this one
returns. They take it directly, or take a session, window, pane or client that
was read through it. The cmdlets fall into a few groups:

**Connecting.** [`New-TmuxServer`](/en/powershell/latest/reference/libtmux-new-tmuxserver/) builds the handle. [`Connect-TmuxServer`](/en/powershell/latest/reference/libtmux-connect-tmuxserver/) discovers
the live server behind it and returns a connected replacement, and
[`Get-TmuxServer`](/en/powershell/latest/reference/libtmux-get-tmuxserver/) reads the daemon's identity and version without starting one.
[`Connect-TmuxControl`](/en/powershell/latest/reference/libtmux-connect-tmuxcontrol/) opens a control client and [`Disconnect-TmuxControl`](/en/powershell/latest/reference/libtmux-disconnect-tmuxcontrol/) closes it.

**Finding one thing.** [`Get-TmuxSession`](/en/powershell/latest/reference/libtmux-get-tmuxsession/) and [`Get-TmuxWindow`](/en/powershell/latest/reference/libtmux-get-tmuxwindow/) select by id or name,
[`Get-TmuxPane`](/en/powershell/latest/reference/libtmux-get-tmuxpane/) by id, and [`Get-TmuxClient`](/en/powershell/latest/reference/libtmux-get-tmuxclient/) by name. A selector that matches nothing
emits nothing. [`Get-TmuxClientAttachment`](/en/powershell/latest/reference/libtmux-get-tmuxclientattachment/) resolves the session, window and pane a
client is viewing.

**Listing everything.** [`Get-TmuxSession`](/en/powershell/latest/reference/libtmux-get-tmuxsession/), [`Get-TmuxWindow`](/en/powershell/latest/reference/libtmux-get-tmuxwindow/), [`Get-TmuxPane`](/en/powershell/latest/reference/libtmux-get-tmuxpane/) and
[`Get-TmuxClient`](/en/powershell/latest/reference/libtmux-get-tmuxclient/) list everything on the server when given no selector. A missing
daemon writes an error instead of returning an empty list. [`Get-TmuxSnapshot`](/en/powershell/latest/reference/libtmux-get-tmuxsnapshot/)
captures the hierarchy to a depth you choose and returns a replacement server.
[`Update-TmuxPane`](/en/powershell/latest/reference/libtmux-update-tmuxpane/) and [`Update-TmuxClient`](/en/powershell/latest/reference/libtmux-update-tmuxclient/) read one object again into a new capture.

**Querying things and getting around.** [`New-TmuxQuery`](/en/powershell/latest/reference/libtmux-new-tmuxquery/) builds reusable criteria.
[`Select-TmuxSession`](/en/powershell/latest/reference/libtmux-select-tmuxsession/), [`Select-TmuxWindow`](/en/powershell/latest/reference/libtmux-select-tmuxwindow/) and [`Select-TmuxPane`](/en/powershell/latest/reference/libtmux-select-tmuxpane/) filter objects you
already captured without contacting tmux, and can require exactly one match.
[`Invoke-TmuxQuery`](/en/powershell/latest/reference/libtmux-invoke-tmuxquery/) acquires fresh objects instead. [`Get-TmuxQueryField`](/en/powershell/latest/reference/libtmux-get-tmuxqueryfield/) lists the
fields and operators, [`Get-TmuxQueryPlan`](/en/powershell/latest/reference/libtmux-get-tmuxqueryplan/) shows how a query will run, and
[`ConvertTo-TmuxQueryJson`](/en/powershell/latest/reference/libtmux-convertto-tmuxqueryjson/) serializes one. To move down the hierarchy, pass a
session to [`Get-TmuxWindow`](/en/powershell/latest/reference/libtmux-get-tmuxwindow/) or [`Get-TmuxPane`](/en/powershell/latest/reference/libtmux-get-tmuxpane/), or a window to [`Get-TmuxPane`](/en/powershell/latest/reference/libtmux-get-tmuxpane/).

**Changing things.** [`New-TmuxSession`](/en/powershell/latest/reference/libtmux-new-tmuxsession/), [`New-TmuxWindow`](/en/powershell/latest/reference/libtmux-new-tmuxwindow/), [`Split-TmuxPane`](/en/powershell/latest/reference/libtmux-split-tmuxpane/) and
[`New-TmuxWindowLink`](/en/powershell/latest/reference/libtmux-new-tmuxwindowlink/) create, and [`New-TmuxSession`](/en/powershell/latest/reference/libtmux-new-tmuxsession/) can start a daemon that is not
running yet. [`Move-TmuxWindow`](/en/powershell/latest/reference/libtmux-move-tmuxwindow/), [`Set-TmuxLayout`](/en/powershell/latest/reference/libtmux-set-tmuxlayout/), [`Set-TmuxPaneSize`](/en/powershell/latest/reference/libtmux-set-tmuxpanesize/) and
[`Set-TmuxWindowSize`](/en/powershell/latest/reference/libtmux-set-tmuxwindowsize/) rearrange. [`Remove-TmuxSession`](/en/powershell/latest/reference/libtmux-remove-tmuxsession/), [`Remove-TmuxWindow`](/en/powershell/latest/reference/libtmux-remove-tmuxwindow/),
[`Remove-TmuxWindowLink`](/en/powershell/latest/reference/libtmux-remove-tmuxwindowlink/) and [`Remove-TmuxPane`](/en/powershell/latest/reference/libtmux-remove-tmuxpane/) delete.

**Options and hooks.** [`Get-TmuxOption`](/en/powershell/latest/reference/libtmux-get-tmuxoption/), [`Set-TmuxOption`](/en/powershell/latest/reference/libtmux-set-tmuxoption/) and [`Remove-TmuxOption`](/en/powershell/latest/reference/libtmux-remove-tmuxoption/)
read, write and unset options on a server, session, window or pane.
[`Get-TmuxHook`](/en/powershell/latest/reference/libtmux-get-tmuxhook/), [`Set-TmuxHook`](/en/powershell/latest/reference/libtmux-set-tmuxhook/) and [`Remove-TmuxHook`](/en/powershell/latest/reference/libtmux-remove-tmuxhook/) do the same for hooks, and
[`Invoke-TmuxHook`](/en/powershell/latest/reference/libtmux-invoke-tmuxhook/) runs one now. [`Get-TmuxEnvironment`](/en/powershell/latest/reference/libtmux-get-tmuxenvironment/), [`Set-TmuxEnvironment`](/en/powershell/latest/reference/libtmux-set-tmuxenvironment/) and
[`Remove-TmuxEnvironment`](/en/powershell/latest/reference/libtmux-remove-tmuxenvironment/) manage the environment table of a server or session.

**Everything else tmux keeps.** [`Send-TmuxText`](/en/powershell/latest/reference/libtmux-send-tmuxtext/) and [`Send-TmuxKey`](/en/powershell/latest/reference/libtmux-send-tmuxkey/) type into a pane,
[`Get-TmuxPaneContent`](/en/powershell/latest/reference/libtmux-get-tmuxpanecontent/) reads what it shows, and [`Wait-TmuxPaneText`](/en/powershell/latest/reference/libtmux-wait-tmuxpanetext/) waits for text to
appear. [`Invoke-TmuxPaneCommand`](/en/powershell/latest/reference/libtmux-invoke-tmuxpanecommand/) runs a shell command in a pane and reports its
exit status. [`Wait-TmuxChannel`](/en/powershell/latest/reference/libtmux-wait-tmuxchannel/) waits for a channel signal, and [`Watch-TmuxEvent`](/en/powershell/latest/reference/libtmux-watch-tmuxevent/)
streams events from a control client.

**Things that need a terminal.** [`Enter-TmuxSession`](/en/powershell/latest/reference/libtmux-enter-tmuxsession/) attaches your foreground
terminal to a session and returns when you detach. Run it outside tmux; it
rejects redirected input.

Anything tmux can do that is not here is reachable through [`Invoke-TmuxCommand`](/en/powershell/latest/reference/libtmux-invoke-tmuxcommand/),
which runs literal tmux arguments and returns the result. [`Invoke-TmuxChain`](/en/powershell/latest/reference/libtmux-invoke-tmuxchain/) runs
several commands in order, [`New-TmuxCommand`](/en/powershell/latest/reference/libtmux-new-tmuxcommand/) builds one without running it, and
[`Invoke-TmuxControlCommand`](/en/powershell/latest/reference/libtmux-invoke-tmuxcontrolcommand/) sends one over a control client.

### Notes

The returned [`LibTmux.Server`](/en/csharp/latest/reference/libtmux-server/) is unmaterialized. TmuxBinaryPath and [`ConfigurationFile`](/en/csharp/latest/reference/libtmux-serverconnectionoptions-configurationfile/) affect subsequent operations; construction does not execute them.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Default parameter set:** Name
- **Positional binding:** Enabled.
- **Outputs:** `LibTmux.Server`

Related APIs:

- [Task guide](https://github.com/libtmux/libtmux-powershell/blob/fa5e60c48b312eb0d957d02aad9edcfc50cff359/docs/read.md)

## Examples

Example 1

Construct a handle for the existing socket identified by $SocketPath.

[Source example](https://github.com/libtmux/libtmux-powershell/blob/fa5e60c48b312eb0d957d02aad9edcfc50cff359/docs/reference/LibTmux/New-TmuxServer.md).

```powershell
LibTmux\New-TmuxServer -SocketPath $SocketPath
```

## Parameters

- `SocketName` (`System.String`): The tmux socket name, passed as -L. It beats LIBTMUX_SOCKET and
LIBTMUX_SOCKET_PATH. (for `Name`)
  Optional. Named parameter. Does not accept pipeline input. [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0).
- `TmuxBinaryPath` (`System.String`): The tmux executable used by subsequent operations.
  Optional. Named parameter. Does not accept pipeline input. [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0).
- `ConfigurationFile` (`System.String`): The configuration used if a later operation starts tmux.
  Optional. Named parameter. Does not accept pipeline input. [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0).
- `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`.
- `SocketPath` (`System.String`): The absolute socket path, passed as -S. It beats LIBTMUX_SOCKET and
LIBTMUX_SOCKET_PATH. (for `Path`)
  Required. Named parameter. Does not accept pipeline input. [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0).

## Returns

`LibTmux.Server`: Native pipeline type for this command.

## Guides

Pages that discuss `New-TmuxServer`.

### Concepts

- [Captured state and I/O](/en/powershell/latest/concepts/captured-state/)
- [Object identity and placement](/en/powershell/latest/concepts/identity/)

### Guides

- [Attaching to tmux](/en/powershell/latest/guides/attaching-to-tmux/)
- [Getting started](/en/powershell/latest/guides/getting-started/)
- [Troubleshooting](/en/powershell/latest/guides/troubleshooting/)

### Topics

- [Ownership and cleanup](/en/powershell/latest/topics/ownership/)

## In other ports

A tmux server

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Server`](/en/py/latest/reference/libtmux-server/) (class) |
| Ruby | [`LibTmux::Server`](/en/ruby/latest/reference/libtmux-server/) (class) |
| Lua | [`libtmux.Server`](/en/lua/latest/reference/libtmux-server/) (class) |
| Julia | [`LibTmux.Server`](/en/julia/latest/reference/libtmux-server/) (struct). `Server` describes an endpoint without contacting tmux. Read its hierarchy with `snapshot`. |
| Elixir | [`LibTmux.Server`](/en/elixir/latest/reference/libtmux-server/) (struct). `Server` describes an existing server by executable and socket. It neither connects nor reserves the server’s identity. |
| TypeScript | [`server.Server`](/en/ts/latest/reference/server-server/) (class) |
| Rust | [`server.Server`](/en/rs/latest/reference/server-server/) (struct) |
| Go | [`tmux.Server`](/en/go/latest/reference/tmux-server/) (struct) |
| Java | [`io.github.libtmux.Server`](/en/java/latest/reference/io-github-libtmux-server-server/) (class) |
| Kotlin | [`io.github.libtmux.kotlin.Server`](/en/kotlin/latest/reference/io-github-libtmux-kotlin-server/) (class) |
| Scala | [`io.github.libtmux.scaladsl.Server`](/en/scala/latest/reference/io-github-libtmux-scaladsl-server/) (typealias) |
| C# | [`LibTmux.Server`](/en/csharp/latest/reference/libtmux-server/) (class) |
| F# | [`LibTmux.FSharp.Server`](/en/fsharp/latest/reference/libtmux-fsharp-server/) (module). This F# module provides functions over the shared .NET `LibTmux.Server` type. |
| C++ | [`libtmux::Server`](/en/cxx/latest/reference/libtmux-server/) (class) |
| Swift | [`Server`](/en/swift/latest/reference/server/) (struct) |
