libtmux for PowerShell
PowerShell-based tmux client
tmux client library for PowerShell. Control tmux, connect to and create servers, navigate sessions, windows, and panes, send keys, watch for changes via control mode, capture pane contents
$ErrorActionPreference = 'Stop'Import-Module "$PSScriptRoot/modules/LibTmux/0.1.0/LibTmux.psd1"
# A private server: a socket and an empty config of its own, so this# neither touches nor is changed by a tmux you already use.# The process ID in the socket name keeps one run apart from the next.$socket = 'libtmux-home-' + $PID$server = New-TmuxServer -SocketName $socket -ConfigurationFile /dev/null$session = $server | New-TmuxSession -Name demo
# Lay out the session: name its window, split it, add a second window.$window = $session | Get-TmuxWindow | Where-Object Active$editor = $window.RenameAsync('editor').GetAwaiter().GetResult()$left = $editor | Get-TmuxPane | Where-Object Active$right = $left | Split-TmuxPane -Horizontal$logs = $session | New-TmuxWindow -Name logs
# Type a command into the new pane and wait for what it prints.$right | Send-TmuxText -Text "printf 'hello from %s\n' tmux" -Enter$found = $right | Wait-TmuxPaneText -Pattern 'hello from tmux' -Timeout 10if (-not $found.Found) { throw 'the pane never showed the output' }
# Move the focus an attached client sees: the pane, then the window.$request = [LibTmux.SelectPaneRequest]::new()$right = $right.SelectAsync($request).GetAwaiter().GetResult()$logs = $logs.SelectAsync().GetAwaiter().GetResult()
# Walk the objects: down from the server, then up from one pane.$snapshot = $server | Get-TmuxSnapshotforeach ($each in $snapshot.Sessions) { "session $($each.Name)" foreach ($window in $each.Windows) { ' window {0}:{1}: {2}' -f $window.Index, $window.Name, ($window.Panes.Id -join ' ') }}$pane = $snapshot.Panes | Where-Object Id -eq $right.Id$window = $pane.Window$owner = $pane.Session"$($pane.Id) is in window $($window.Name) of session $($owner.Name)"$ErrorActionPreference = 'Stop'Import-Module "$PSScriptRoot/modules/LibTmux/0.1.0/LibTmux.psd1"
try { # A private server: a socket and an empty config of its own, so this # neither touches nor is changed by a tmux you already use. # The process ID in the socket name keeps one run apart from the next. $socket = 'libtmux-home-' + $PID $server = New-TmuxServer -SocketName $socket -ConfigurationFile /dev/null $session = $server | New-TmuxSession -Name demo
# Lay out the session: name its window, split it, add a second window. $window = $session | Get-TmuxWindow | Where-Object Active $editor = $window.RenameAsync('editor').GetAwaiter().GetResult() $left = $editor | Get-TmuxPane | Where-Object Active $right = $left | Split-TmuxPane -Horizontal $logs = $session | New-TmuxWindow -Name logs
# Type a command into the new pane and wait for what it prints. $right | Send-TmuxText -Text "printf 'hello from %s\n' tmux" -Enter $found = $right | Wait-TmuxPaneText -Pattern 'hello from tmux' -Timeout 10 if (-not $found.Found) { throw 'the pane never showed the output' }
# Move the focus an attached client sees: the pane, then the window. $request = [LibTmux.SelectPaneRequest]::new() $right = $right.SelectAsync($request).GetAwaiter().GetResult() $logs = $logs.SelectAsync().GetAwaiter().GetResult()
# Walk the objects: down from the server, then up from one pane. $snapshot = $server | Get-TmuxSnapshot foreach ($each in $snapshot.Sessions) { "session $($each.Name)" foreach ($window in $each.Windows) { ' window {0}:{1}: {2}' -f $window.Index, $window.Name, ($window.Panes.Id -join ' ') } } $pane = $snapshot.Panes | Where-Object Id -eq $right.Id $window = $pane.Window $owner = $pane.Session "$($pane.Id) is in window $($window.Name) of session $($owner.Name)"} catch { $failure = [InvalidOperationException]::new( "tmux quickstart failed: $($_.Exception.Message)", $_.Exception) throw $failure}$ErrorActionPreference = 'Stop'Import-Module "$PSScriptRoot/modules/LibTmux/0.1.0/LibTmux.psd1"
$session = $null$failure = $nulltry { # A private server: a socket and an empty config of its own, so this # neither touches nor is changed by a tmux you already use. # The process ID in the socket name keeps one run apart from the next. $socket = 'libtmux-home-' + $PID $server = New-TmuxServer -SocketName $socket -ConfigurationFile /dev/null $session = $server | New-TmuxSession -Name demo
# Lay out the session: name its window, split it, add a second window. $window = $session | Get-TmuxWindow | Where-Object Active $editor = $window.RenameAsync('editor').GetAwaiter().GetResult() $left = $editor | Get-TmuxPane | Where-Object Active $right = $left | Split-TmuxPane -Horizontal $logs = $session | New-TmuxWindow -Name logs
# Type a command into the new pane and wait for what it prints. $right | Send-TmuxText -Text "printf 'hello from %s\n' tmux" -Enter $found = $right | Wait-TmuxPaneText -Pattern 'hello from tmux' -Timeout 10 if (-not $found.Found) { throw 'the pane never showed the output' }
# Move the focus an attached client sees: the pane, then the window. $request = [LibTmux.SelectPaneRequest]::new() $right = $right.SelectAsync($request).GetAwaiter().GetResult() $logs = $logs.SelectAsync().GetAwaiter().GetResult()
# Walk the objects: down from the server, then up from one pane. $snapshot = $server | Get-TmuxSnapshot foreach ($each in $snapshot.Sessions) { "session $($each.Name)" foreach ($window in $each.Windows) { ' window {0}:{1}: {2}' -f $window.Index, $window.Name, ($window.Panes.Id -join ' ') } } $pane = $snapshot.Panes | Where-Object Id -eq $right.Id $window = $pane.Window $owner = $pane.Session "$($pane.Id) is in window $($window.Name) of session $($owner.Name)"} catch { $failure = $_.Exception throw} finally { if ($session) { $cleanupErrors = @() $session | Remove-TmuxSession -Confirm:$false ` -ErrorAction SilentlyContinue -ErrorVariable cleanupErrors if ($cleanupErrors) { if ($failure) { $errors = @($failure) + $cleanupErrors.Exception throw [AggregateException]::new( 'tmux operation and cleanup failed.', [Exception[]]$errors) } throw $cleanupErrors[0] } }}$ErrorActionPreference = 'Stop'Import-Module "$PSScriptRoot/modules/LibTmux/0.1.0/LibTmux.psd1"
$session = $null$failure = $nulltry { # A private server: a socket and an empty config of its own, so this # neither touches nor is changed by a tmux you already use. # The process ID in the socket name keeps one run apart from the next. $socket = 'libtmux-home-' + $PID $server = New-TmuxServer -SocketName $socket -ConfigurationFile /dev/null $session = $server | New-TmuxSession -Name demo
# Lay out the session: name its window, split it, add a second window. $window = $session | Get-TmuxWindow | Where-Object Active $editor = $window.RenameAsync('editor').GetAwaiter().GetResult() $left = $editor | Get-TmuxPane | Where-Object Active $right = $left | Split-TmuxPane -Horizontal $logs = $session | New-TmuxWindow -Name logs
# Type a command into the new pane and wait for what it prints. $right | Send-TmuxText -Text "printf 'hello from %s\n' tmux" -Enter $found = $right | Wait-TmuxPaneText -Pattern 'hello from tmux' -Timeout 10 if (-not $found.Found) { throw 'the pane never showed the output' }
# Move the focus an attached client sees: the pane, then the window. $request = [LibTmux.SelectPaneRequest]::new() $right = $right.SelectAsync($request).GetAwaiter().GetResult() $logs = $logs.SelectAsync().GetAwaiter().GetResult()
# Walk the objects: down from the server, then up from one pane. $snapshot = $server | Get-TmuxSnapshot foreach ($each in $snapshot.Sessions) { "session $($each.Name)" foreach ($window in $each.Windows) { ' window {0}:{1}: {2}' -f $window.Index, $window.Name, ($window.Panes.Id -join ' ') } } $pane = $snapshot.Panes | Where-Object Id -eq $right.Id $window = $pane.Window $owner = $pane.Session "$($pane.Id) is in window $($window.Name) of session $($owner.Name)"} catch { $failure = [InvalidOperationException]::new( "tmux quickstart failed: $($_.Exception.Message)", $_.Exception) throw $failure} finally { if ($session) { $cleanupErrors = @() $session | Remove-TmuxSession -Confirm:$false ` -ErrorAction SilentlyContinue -ErrorVariable cleanupErrors if ($cleanupErrors) { if ($failure) { $errors = @($failure) + $cleanupErrors.Exception throw [AggregateException]::new( 'tmux operation and cleanup failed.', [Exception[]]$errors) } throw $cleanupErrors[0] } }}tmux before the first call: no server is running.
tmux after New-TmuxServer: no server is running; the call sent no command.
tmux after New-TmuxSession: added session demo.
tmux after Get-TmuxWindow: unchanged.
tmux after Window.RenameAsync: renamed window 0:sh to 0:editor.
tmux after Get-TmuxPane: unchanged.
tmux after Split-TmuxPane: added pane %1 to window 0:editor.
tmux after New-TmuxWindow: added window 1:logs.
tmux after Send-TmuxText: sent keys to pane %1.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Wait-TmuxPaneText: read pane %1.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Pane.SelectAsync: selected pane %1 in window 0:editor.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Window.SelectAsync: selected window 1:logs.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Get-TmuxSnapshot: unchanged.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Snapshot.Panes: unchanged, the call sent no command.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Pane.Window: unchanged, the call sent no command.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Pane.Session: unchanged, the call sent no command.
tmux after Remove-TmuxSession: the server has exited.
Before the first call
No tmux server is running yet.
New-TmuxServer returned Server
{ "socketName": "libtmux-home-12345", "configFile": "/dev/null"}The call sent no tmux command.
New-TmuxSession returned Session
{ "id": "$0", "name": "demo"}3 tmux commands, 2 that change tmux
-
new-session -P -F '#{pid}:#{start_time} #{session_id} #{window_id} #{pane_id} #{window_index}' -d -s demo3510344:1793891486 $0 @0 %0 0 -
attach-session -f ignore-size,no-output,new-layoutsno output -
display-message -p -t $0 #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_ind…/dev/nullLT945f7a6878c6439da904d2LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d20LT945f7a6878c6439da904d20LT945f7a6878c6439da904d21793891487LT945f7a6878c6439da904d2LT945f7a…
Before these, the library asked tmux about itself 4 times (its version, its daemon, how a control client reads escapes).
1 notification from tmux while the call ran
%session-changed $0 demo
Get-TmuxWindow returned Window
{ "id": "@0", "index": 0, "name": "sh"}1 tmux command
-
list-windows -t $0 -F #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_index}…/dev/nullLT945f7a6878c6439da904d21LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d20LT945f7a6878c6439da904d20LT945f7a6878c6439da904d21793891487LT945f7a6878c6439da904d2LT945f7…
Window.RenameAsync returned Window
{ "id": "@0", "index": 0, "name": "editor"}2 tmux commands, 1 that changes tmux
-
rename-window -t @0 -- editorno output -
display-message -p -t $0:0 #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_i…/dev/nullLT945f7a6878c6439da904d2LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d20LT945f7a6878c6439da904d20LT945f7a6878c6439da904d21793891487LT945f7a6878c6439da904d2LT945f7a…
1 notification from tmux while the call ran
%window-renamed @0 editor
Get-TmuxPane returned Pane
{ "id": "%0"}1 tmux command
-
list-panes -t $0:0 -F #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_index}…/dev/nullLT945f7a6878c6439da904d21LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d20LT945f7a6878c6439da904d20LT945f7a6878c6439da904d21793891487LT945f7a6878c6439da904d2LT945f7…
Split-TmuxPane returned Pane
{ "id": "%1"}2 tmux commands, 1 that changes tmux
-
split-window -P -F #{pane_id} -t %0 -h -d%1 -
display-message -p -t %1 #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_ind…/dev/nullLT945f7a6878c6439da904d2LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d20LT945f7a6878c6439da904d20LT945f7a6878c6439da904d21793891487LT945f7a6878c6439da904d2LT945f7a…
1 notification from tmux while the call ran
%layout-change @0 {"V":2,"L":{"t":"h","w":80,"h":24,"x":0,"y":0,"c":[{"t":"p","w":40,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"},{"t":"p","w":39,"h":24,"x":41,"y":0,"i":1,"I":"%1"}]}} {"V":2,"L":{"t":"h","w":80,"h":24,"x":0,"y":0,"c":[{"t":"p","w":40,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"},{"t":"p","w":39,"h":24,"x":41,"y":0,"i":1,"I":"%1"}]}} *
New-TmuxWindow returned Window
{ "id": "@1", "index": 1, "name": "logs"}2 tmux commands, 1 that changes tmux
-
new-window -P -F #{window_id} -d -t $0: -n logs@1 -
list-windows -t $0 -F #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_index}…/dev/nullLT945f7a6878c6439da904d22LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d20LT945f7a6878c6439da904d21LT945f7a6878c6439da904d21793891487LT945f7a6878c6439da904d2LT945f7…
1 notification from tmux while the call ran
%window-add @1
Send-TmuxText returned void
null2 tmux commands, 2 that change tmux
-
send-keys -t %1 -l -- 'printf '\''hello from %s\n'\'' tmux'no output -
send-keys -t %1 Enterno output
Wait-TmuxPaneText returned PaneWaitResult
{ "outcome": "PresentAtEntry", "found": true}13 tmux commands, 4 that change tmux
-
attach-session -t $0no output -
refresh-client -f new-layoutsno output -
refresh-client -f ignore-sizeno output -
refresh-client -B libtmux-pane-dead:%*:#{pane_dead}no output -
list-panes -t $0:.%1 -F #{pane_id} -f #{==:#{pane_id},%1}%1 -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3510586 0 2000 24 2 0 0 39 -
capture-pane -t %1 -p$ printf 'hello from %s\n' tmux hello from tmux $ -
capture-pane -t %1 -p -J$ printf 'hello from %s\n' tmux hello from tmux $ -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3510586 0 2000 24 2 0 0 39 -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3510586 0 2000 24 2 0 0 39 -
capture-pane -t %1 -p$ printf 'hello from %s\n' tmux hello from tmux $ -
capture-pane -t %1 -p -J$ printf 'hello from %s\n' tmux hello from tmux $ -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3510586 0 2000 24 2 0 0 39
Before these, the library asked tmux about itself 1 time (its version, its daemon, how a control client reads escapes).
4 notifications from tmux while the call ran
%client-session-changed client-3510845 $0 demo%session-changed $0 demo%exit%client-detached client-3510845
Pane.SelectAsync returned Pane
{ "id": "%1"}2 tmux commands, 1 that changes tmux
-
select-pane -t %1no output -
display-message -p -t $0:.%1 #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window…/dev/nullLT945f7a6878c6439da904d2LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d20LT945f7a6878c6439da904d21LT945f7a6878c6439da904d21793891490LT945f7a6878c6439da904d2LT945f7a…
1 notification from tmux while the call ran
%window-pane-changed @0 %1
Window.SelectAsync returned Window
{ "id": "@1", "index": 1, "name": "logs"}2 tmux commands, 1 that changes tmux
-
select-window -t @1no output -
display-message -p -t $0:1 #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_i…/dev/nullLT945f7a6878c6439da904d2LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d21LT945f7a6878c6439da904d21LT945f7a6878c6439da904d21793891490LT945f7a6878c6439da904d2LT945f7a…
1 notification from tmux while the call ran
%session-window-changed $0 @1
Get-TmuxSnapshot returned Snapshot
{ "sessions": 1, "windows": 2, "panes": 3}3 tmux commands
-
list-sessions -F #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_index}LT945…/dev/nullLT945f7a6878c6439da904d20LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d21LT945f7a6878c6439da904d21LT945f7a6878c6439da904d21793891490LT945f7a6878c6439da904d2LT945f7… -
list-windows -a -F #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_index}LT9…/dev/nullLT945f7a6878c6439da904d22LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d21LT945f7a6878c6439da904d21LT945f7a6878c6439da904d21793891490LT945f7a6878c6439da904d2LT945f7… -
list-panes -a -F #{config_files}LT945f7a6878c6439da904d2#{line}LT945f7a6878c6439da904d2#{next_session_id}LT945f7a6878c6439da904d2#{pid}LT945f7a6878c6439da904d2#{socket_path}LT945f7a6878c6439da904d2#{start_time}LT945f7a6878c6439da904d2#{uid}LT945f7a6878c6439da904d2#{user}LT945f7a6878c6439da904d2#{version}LT945f7a6878c6439da904d2#{active_window_index}LT945f7a6878c6439da904d2#{last_window_index}LT945…/dev/nullLT945f7a6878c6439da904d22LT945f7a6878c6439da904d2$1LT945f7a6878c6439da904d23510344LT945f7a6878c6439da904d2/tmp/tmux-1000/libtmux-home-12345LT945f7a6878c6439da904d21793891486LT945f7a6878c6439da904d21000LT945f7a6878c6439da904d2dLT945f7a6878c6439da904d23.8aLT945f7a6878c6439da904d21LT945f7a6878c6439da904d21LT945f7a6878c6439da904d21793891490LT945f7a6878c6439da904d2LT945f7…
Before these, the library asked tmux about itself 1 time (its version, its daemon, how a control client reads escapes).
Snapshot.Panes returned Pane
{ "id": "%1"}The call sent no tmux command.
Pane.Window returned Window
{ "id": "@0", "index": 0, "name": "editor"}The call sent no tmux command.
Pane.Session returned Session
{ "id": "$0", "name": "demo"}The call sent no tmux command.
Remove-TmuxSession returned void
{ "errors": 0}1 tmux command, 1 that changes tmux
-
kill-session -t $03510344:1793891486
1 notification from tmux while the call ran
%exit
Run this example
PowerShell 7.4.20 with PSResourceGet 1.1.1, POSIX shell and tmux on Linux.
Save the program above as quickstart.ps1 in a new directory, along with the files below.
Cleanup is omitted; the private tmux server and its temporary files may remain. Select Cleanup to remove them when the program finishes. The program stops its private tmux server and removes any temporary files it created when it finishes. Error handling adds diagnostics; every version checks required results and deadlines.
Setup and run
pwsh -NoLogo -NoProfile -Command ' $ErrorActionPreference = "Stop" $null = New-Item -ItemType Directory -Path ./modules -Force Save-PSResource -Name LibTmux -Version 0.1.0 ` -Path ./modules -TrustRepository'unset TMUX TMUX_PANEexport ENV=/dev/null BASH_ENV=/dev/null SHELL=/bin/shpwsh -NoLogo -NoProfile -File quickstart.ps1Expected output
session demo window 0:editor: %0 %1 window 1:logs: %2%1 is in window editor of session demoInstall LibTmux
Install-Module -Name LibTmuxRequires PowerShell 7.4 or later and tmux on the same Unix host.
Install-PSResource -Name LibTmuxRequires PowerShell 7.4 or later and tmux on the same Unix host.
MCP
PowerShell has no MCP package of its own. It uses the C# port's LibTmux.Mcp.
Install LibTmux.Mcp
Choose your client and configuration scope, then run the command or paste the configuration.
$ claude mcp add tmux -- dnx LibTmux.Mcp --yesRuns the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: ~/.claude.json (this project)
$ claude mcp add tmux --scope user -- dnx LibTmux.Mcp --yesRuns the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: ~/.claude.json (all projects)
$ claude mcp add tmux --scope project -- dnx LibTmux.Mcp --yesRuns the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: .mcp.json (in repo, version-controlled)
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
$ claude mcp add tmux -- libtmux-mcpInstalls the `libtmux-mcp` tool from NuGet.
Config file: ~/.claude.json (this project)
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
$ claude mcp add tmux --scope user -- libtmux-mcpInstalls the `libtmux-mcp` tool from NuGet.
Config file: ~/.claude.json (all projects)
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
$ claude mcp add tmux --scope project -- libtmux-mcpInstalls the `libtmux-mcp` tool from NuGet.
Config file: .mcp.json (in repo, version-controlled)
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: claude_desktop_config.json
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen use this config:
Installs the `libtmux-mcp` tool from NuGet.
Config file: claude_desktop_config.json
$ codex mcp add tmux -- dnx LibTmux.Mcp --yesRuns the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: ~/.codex/config.toml
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: .codex/config.toml (in repo)
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
$ codex mcp add tmux -- libtmux-mcpInstalls the `libtmux-mcp` tool from NuGet.
Config file: ~/.codex/config.toml
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
Installs the `libtmux-mcp` tool from NuGet.
Config file: .codex/config.toml (in repo)
$ gemini mcp add --scope user tmux dnx -- LibTmux.Mcp --yesRuns the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: ~/.gemini/settings.json
$ gemini mcp add --scope project tmux dnx -- LibTmux.Mcp --yesRuns the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: .gemini/settings.json (in repo)
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
$ gemini mcp add --scope user tmux libtmux-mcpInstalls the `libtmux-mcp` tool from NuGet.
Config file: ~/.gemini/settings.json
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
$ gemini mcp add --scope project tmux libtmux-mcpInstalls the `libtmux-mcp` tool from NuGet.
Config file: .gemini/settings.json (in repo)
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: .cursor/mcp.json (in repo)
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: ~/.cursor/mcp.json
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen use this config:
Installs the `libtmux-mcp` tool from NuGet.
Config file: .cursor/mcp.json (in repo)
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen use this config:
Installs the `libtmux-mcp` tool from NuGet.
Config file: ~/.cursor/mcp.json
$ grok mcp add --scope user tmux -- dnx LibTmux.Mcp --yesRuns the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: ~/.grok/config.toml
$ grok mcp add --scope project tmux -- dnx LibTmux.Mcp --yesRuns the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: ./.grok/config.toml (in repo)
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
$ grok mcp add --scope user tmux -- libtmux-mcpInstalls the `libtmux-mcp` tool from NuGet.
Config file: ~/.grok/config.toml
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
$ grok mcp add --scope project tmux -- libtmux-mcpInstalls the `libtmux-mcp` tool from NuGet.
Config file: ./.grok/config.toml (in repo)
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: ~/.gemini/config/mcp_config.json
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen use this config:
Installs the `libtmux-mcp` tool from NuGet.
Config file: ~/.gemini/config/mcp_config.json
$ opencode mcp add tmux -- dnx LibTmux.Mcp --yesRuns the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Config file: ~/.config/opencode/opencode.jsonc
Build or install the server first:
$ dotnet tool install --global LibTmux.McpThen register:
$ opencode mcp add tmux -- libtmux-mcpInstalls the `libtmux-mcp` tool from NuGet.
Config file: ~/.config/opencode/opencode.jsonc
Embed the server in a program
Dictionary<string, string?> environment = StdioClientTransportOptions.GetDefaultEnvironmentVariables();environment["LIBTMUX_SOCKET"] = server.ConnectionOptions.SocketName;environment["TMUX_TMPDIR"] = Environment.GetEnvironmentVariable("TMUX_TMPDIR");environment["DOTNET_ROOT"] = Environment.GetEnvironmentVariable("DOTNET_ROOT");environment["LIBTMUX_TOOLSETS"] = "inspect,manage,execute";environment["LIBTMUX_EXCLUDE_TOOLS"] = "run_shell_command";
var transport = new StdioClientTransport(new StdioClientTransportOptions{ Name = "tmux", Command = Environment.GetEnvironmentVariable("LIBTMUX_MCP_COMMAND") ?? "libtmux-mcp", InheritEnvironmentVariables = false, EnvironmentVariables = environment,});McpClient client = await McpClient.CreateAsync( transport, cancellationToken: ct);
Excerpt of examples/LibTmux.Examples/Snippets/Mcp.cs,
which dotnet test --project tests/LibTmux.ExampleTests/LibTmux.ExampleTests.csproj runs in the repository's CI
(.github/workflows/dotnet.yml).
Workspace Manager
Main-horizontal layout
The main-horizontal layout gives the first pane the top of the window and splits the rest below it.
session_name: test window optionsstart_directory: '~'windows:- layout: main-horizontal options: main-pane-height: 5 panes: - pane - pane - pane window_name: editor{ "session_name": "test window options", "start_directory": "~", "windows": [ { "layout": "main-horizontal", "options": { "main-pane-height": 5 }, "panes": [ "pane", "pane", "pane" ], "window_name": "editor" } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-window_options.yaml.
Tested by window options fixture
(tests/WorkspaceCorpus.Tests.ps1; a test runs the command).
Short-hand panes
A pane can be one command written as a string, and a command list can be one string.
session_name: shorthandswindows: - window_name: long form panes: - shell_command: - echo 'did you know' - echo 'you can inline' - shell_command: echo 'single commands' - echo 'for panes'{ "session_name": "shorthands", "windows": [ { "window_name": "long form", "panes": [ { "shell_command": [ "echo 'did you know'", "echo 'you can inline'" ] }, { "shell_command": "echo 'single commands'" }, "echo 'for panes'" ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-shorthands.yaml.
Tested by tmuxp example catalog
(tests/WorkspaceFiles.Tests.ps1; loaded by the library in a test; the command is not run).
Two panes
A window of two panes.
session_name: 2-pane-verticalwindows: - window_name: my test window panes: - echo hello - echo hello{ "session_name": "2-pane-vertical", "windows": [ { "window_name": "my test window", "panes": [ "echo hello", "echo hello" ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-2-pane-vertical.yaml.
Tested by tmuxp example catalog
(tests/WorkspaceFiles.Tests.ps1; loaded by the library in a test; the command is not run).
Three panes
A window of three panes.
session_name: 3-paneswindows: - window_name: dev window layout: main-vertical shell_command_before: - cd ~/ panes: - shell_command: - cd /var/log - ls -al | grep \.log - echo hello - echo hello{ "session_name": "3-panes", "windows": [ { "window_name": "dev window", "layout": "main-vertical", "shell_command_before": [ "cd ~/" ], "panes": [ { "shell_command": [ "cd /var/log", "ls -al | grep \\.log" ] }, "echo hello", "echo hello" ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-3-pane.yaml.
Tested by tmuxp example catalog
(tests/WorkspaceFiles.Tests.ps1; loaded by the library in a test; the command is not run).
Four panes
A window of four panes.
session_name: 4-pane-splitwindows: - window_name: dev window layout: tiled shell_command_before: - cd ~/ panes: - shell_command: - cd /var/log - ls -al | grep \.log - echo hello - echo hello - echo hello{ "session_name": "4-pane-split", "windows": [ { "window_name": "dev window", "layout": "tiled", "shell_command_before": [ "cd ~/" ], "panes": [ { "shell_command": [ "cd /var/log", "ls -al | grep \\.log" ] }, "echo hello", "echo hello", "echo hello" ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-4-pane.yaml.
Tested by tmuxp example catalog
(tests/WorkspaceFiles.Tests.ps1; loaded by the library in a test; the command is not run).
Setup before each pane
shell_command_before runs ahead of a pane's own commands, at the session, window or pane level.
session_name: corpusstart_directory: ${PROJECT_ROOT}options: default-command: exec /bin/sh '@corpus-session': yaml-originalenvironment: CORPUS_SESSION: yaml-root CORPUS_LAYER: sessionshell_command_before: - cmd: echo session >> order.txtwindows: - window_name: yaml-editor start_directory: window layout: even-horizontal focus: true options: '@corpus-window': '${OPTION_TAG}' environment: CORPUS_WINDOW: yaml-window CORPUS_LAYER: window shell_command_before: - cmd: echo window >> order.txt panes: - shell_command: - cmd: echo command >> order.txt - 'echo "$CORPUS_SESSION|$CORPUS_WINDOW|$CORPUS_PANE|$CORPUS_LAYER" > environment.txt' - tmux wait-for -S corpus-yaml-first - start_directory: pane focus: true options: '@corpus-pane': yaml environment: CORPUS_PANE: yaml-pane CORPUS_LAYER: pane shell_command_before: - cmd: echo pane >> order.txt shell_command: - echo command >> order.txt - 'echo "$CORPUS_SESSION|$CORPUS_WINDOW|$CORPUS_PANE|$CORPUS_LAYER" > environment.txt' - tmux wait-for -S corpus-yaml-second{ "session_name": "corpus", "start_directory": "${PROJECT_ROOT}", "options": { "default-command": "exec /bin/sh", "@corpus-session": "yaml-original" }, "environment": { "CORPUS_SESSION": "yaml-root", "CORPUS_LAYER": "session" }, "shell_command_before": [ { "cmd": "echo session >> order.txt" } ], "windows": [ { "window_name": "yaml-editor", "start_directory": "window", "layout": "even-horizontal", "focus": true, "options": { "@corpus-window": "${OPTION_TAG}" }, "environment": { "CORPUS_WINDOW": "yaml-window", "CORPUS_LAYER": "window" }, "shell_command_before": [ { "cmd": "echo window >> order.txt" } ], "panes": [ { "shell_command": [ { "cmd": "echo command >> order.txt" }, "echo \"$CORPUS_SESSION|$CORPUS_WINDOW|$CORPUS_PANE|$CORPUS_LAYER\" > environment.txt", "tmux wait-for -S corpus-yaml-first" ] }, { "start_directory": "pane", "focus": true, "options": { "@corpus-pane": "yaml" }, "environment": { "CORPUS_PANE": "yaml-pane", "CORPUS_LAYER": "pane" }, "shell_command_before": [ { "cmd": "echo pane >> order.txt" } ], "shell_command": [ "echo command >> order.txt", "echo \"$CORPUS_SESSION|$CORPUS_WINDOW|$CORPUS_PANE|$CORPUS_LAYER\" > environment.txt", "tmux wait-for -S corpus-yaml-second" ] } ] } ]}
Workspace file: tests/fixtures/workspace/corpus.yaml.
Tested by corpus fixture
(tests/WorkspaceCorpus.Tests.ps1; a test runs the command).
Environment
environment sets variables for a session, a window or a pane.
session_name: test env varsstart_directory: "~"environment: FOO: SESSION PATH: /tmpwindows:- window_name: no_overrides panes: - pane- window_name: window_overrides environment: FOO: WINDOW panes: - pane- window_name: pane_overrides panes: - environment: FOO: PANE- window_name: both_overrides environment: FOO: WINDOW panes: - pane - environment: FOO: PANE# This test case it just needed for warnings issued in old versions of tmux.- window_name: both_overrides_on_first_pane environment: FOO: WINDOW panes: - environment: FOO: PANE{ "session_name": "test env vars", "start_directory": "~", "environment": { "FOO": "SESSION", "PATH": "/tmp" }, "windows": [ { "window_name": "no_overrides", "panes": [ "pane" ] }, { "window_name": "window_overrides", "environment": { "FOO": "WINDOW" }, "panes": [ "pane" ] }, { "window_name": "pane_overrides", "panes": [ { "environment": { "FOO": "PANE" } } ] }, { "window_name": "both_overrides", "environment": { "FOO": "WINDOW" }, "panes": [ "pane", { "environment": { "FOO": "PANE" } } ] }, { "window_name": "both_overrides_on_first_pane", "environment": { "FOO": "WINDOW" }, "panes": [ { "environment": { "FOO": "PANE" } } ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-environment_vars.yaml.
Tested by environment variables fixture
(tests/WorkspaceCorpus.Tests.ps1; a test runs the command).
Start directory
start_directory chooses where a session, a window or a pane starts.
session_name: sample workspacewindows: - panes: - start_directory: /usr - start_directory: /etc{ "session_name": "sample workspace", "windows": [ { "panes": [ { "start_directory": "/usr" }, { "start_directory": "/etc" } ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-first_pane_start_directory.yaml.
Tested by first pane start directory fixture
(tests/WorkspaceCorpus.Tests.ps1; a test runs the command).
Synchronized panes
options_after sets synchronize-panes once the panes exist, so typing in one pane reaches the others.
session_name: 2-pane-synchronizedwindows: - window_name: Two synchronized panes panes: - ssh server1 - ssh server2 options_after: synchronize-panes: on{ "session_name": "2-pane-synchronized", "windows": [ { "window_name": "Two synchronized panes", "panes": [ "ssh server1", "ssh server2" ], "options_after": { "synchronize-panes": "on" } } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-2-pane-synchronized.yaml.
Tested by tmuxp example catalog
(tests/WorkspaceFiles.Tests.ps1; loaded by the library in a test; the command is not run).
Main pane height as a percentage
main-pane-height takes a percentage of the window as well as a row count.
session_name: main-pane-heightstart_directory: "~"windows: - layout: main-horizontal options: main-pane-height: 67% panes: - shell_command: - top start_directory: "~" - shell_command: - echo "hey" - shell_command: - echo "moo" window_name: my window name{ "session_name": "main-pane-height", "start_directory": "~", "windows": [ { "layout": "main-horizontal", "options": { "main-pane-height": "67%" }, "panes": [ { "shell_command": [ "top" ], "start_directory": "~" }, { "shell_command": [ "echo \"hey\"" ] }, { "shell_command": [ "echo \"moo\"" ] } ], "window_name": "my window name" } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-main-pane-height-percentage.yaml.
Tested by tmuxp example catalog
(tests/WorkspaceFiles.Tests.ps1; loaded by the library in a test; the command is not run).
Minimal workspace
A session name and one window with one blank pane.
session_name: My tmux sessionwindows: - panes: -{ "session_name": "My tmux session", "windows": [ { "panes": [ null ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-minimal.yaml.
Tested by tmuxp example catalog
(tests/WorkspaceFiles.Tests.ps1; loaded by the library in a test; the command is not run).
tmux options
global_options, options and a window's options set tmux options.
session_name: test window optionsstart_directory: "~"global_options: default-shell: /bin/sh default-command: /bin/shoptions: main-pane-height: ${MAIN_PANE_HEIGHT} # works with env variableswindows: - layout: main-horizontal options: automatic-rename: on panes: - shell_command: - man echo start_directory: "~" - shell_command: - echo "hey" - shell_command: - echo "moo"{ "session_name": "test window options", "start_directory": "~", "global_options": { "default-shell": "/bin/sh", "default-command": "/bin/sh" }, "options": { "main-pane-height": "${MAIN_PANE_HEIGHT}" }, "windows": [ { "layout": "main-horizontal", "options": { "automatic-rename": "on" }, "panes": [ { "shell_command": [ "man echo" ], "start_directory": "~" }, { "shell_command": [ "echo \"hey\"" ] }, { "shell_command": [ "echo \"moo\"" ] } ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-options.yaml.
Tested by tmuxp example catalog
(tests/WorkspaceFiles.Tests.ps1; loaded by the library in a test; the command is not run).
Skip Enter for a command
enter: false types a command without running it.
session_name: Skip command execution (command-level)windows: - panes: - shell_command: # You can see this - echo "___$((11 + 1))___" # This is skipped - cmd: echo "___$((1 + 3))___" enter: false{ "session_name": "Skip command execution (command-level)", "windows": [ { "panes": [ { "shell_command": [ "echo \"___$((11 + 1))___\"", { "cmd": "echo \"___$((1 + 3))___\"", "enter": false } ] } ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-skip-send.yaml.
Tested by skip-send fixture
(tests/WorkspaceCorpus.Tests.ps1; built by the library in a test; the command is not run).
Skip Enter for a pane
enter: false on a pane types its commands without running them.
session_name: Skip command execution (pane-level)windows: - panes: - shell_command: echo "___$((1 + 3))___" enter: false - shell_command: - echo "___$((1 + 3))___"\; - echo "___$((1 + 3))___" enter: false{ "session_name": "Skip command execution (pane-level)", "windows": [ { "panes": [ { "shell_command": "echo \"___$((1 + 3))___\"", "enter": false }, { "shell_command": [ "echo \"___$((1 + 3))___\"\\;", "echo \"___$((1 + 3))___\"" ], "enter": false } ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-skip-send-pane-level.yaml.
Tested by skip-send pane-level fixture
(tests/WorkspaceCorpus.Tests.ps1; built by the library in a test; the command is not run).
Window index
window_index places a window at an index; a window without one takes the lowest free index.
session_name: Window index examplewindows: - window_name: zero panes: - echo "this window's index will be zero" - window_name: five panes: - echo "this window's index will be five" window_index: 5 - window_name: one panes: - echo "this window's index will be one"{ "session_name": "Window index example", "windows": [ { "window_name": "zero", "panes": [ "echo \"this window's index will be zero\"" ] }, { "window_name": "five", "panes": [ "echo \"this window's index will be five\"" ], "window_index": 5 }, { "window_name": "one", "panes": [ "echo \"this window's index will be one\"" ] } ]}
Workspace file: tests/fixtures/workspace/tmuxp-v1.74.0-window-index.yaml.
Tested by tmuxp example catalog
(tests/WorkspaceFiles.Tests.ps1; loaded by the library in a test; the command is not run).
Install LibTmux.Workspace
The workspace package is separate from the core library.
Install-Module -Name LibTmux.WorkspaceInstalls the matching LibTmux core dependency. Run PowerShell and tmux on the same Unix host.
Install-PSResource -Name LibTmux.WorkspaceInstalls the matching LibTmux core dependency. Run PowerShell and tmux on the same Unix host.
Build the workspace from a program
$workspace = LibTmux.Workspace\Import-TmuxWorkspace -Yaml @'session_name: readme-workspace-previewwindows: - window_name: editor panes: - shell_command: exec /bin/sh - shell_command: exec /bin/sh'@
Excerpt of examples/Guides.ps1,
which eng/Test.ps1 -Suite Documentation runs in the repository's CI
(.github/workflows/ci.yml).
Topics
Subject-by-subject, with PowerShell in every code block.
Guides
Task guides for PowerShell.
Examples
Complete programs, sourced from the code each port tests.
Concepts
The domain model every port shares.