C#Home

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

libtmux for C#

C#-based tmux client

tmux client library for C#. Control tmux, connect to and create servers, navigate sessions, windows, and panes, send keys, watch for changes via control mode, capture pane contents

Product
using System;
using System.Linq;
using System.Threading;
using System.Runtime.Versioning;
using LibTmux;
[assembly: UnsupportedOSPlatform("windows")]
if (OperatingSystem.IsWindows())
{
throw new PlatformNotSupportedException(
"This example requires tmux on Unix.");
}
using var deadline = new CancellationTokenSource(
TimeSpan.FromSeconds(30));
var token = deadline.Token;
// 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.
var options = new ServerConnectionOptions
{
SocketName = "quickstart-" + Guid.NewGuid().ToString("N"),
ConfigurationFile = "/dev/null",
TmuxBinaryPath = Environment.GetEnvironmentVariable("LIBTMUX_TMUX")
?? "tmux",
};
var owned = await Server.CreateOwnedAsync(options, token);
Server server = owned.Value;
Session session = await server.CreateSessionAsync(
new NewSessionRequest { Name = "demo", Command = "/bin/sh" },
token);
// Lay out the session: name its window, split it, add a second window.
// Neither the split nor the new window takes the focus.
Window editor = (await session.GetWindowsAsync(token))[0];
editor = await editor.RenameAsync("editor", token);
Pane left = await editor.GetActivePaneAsync(token);
Pane right = await left.SplitAsync(
new SplitPaneRequest
{
Direction = PaneDirection.Right,
Command = "/bin/sh",
},
token);
Window logs = await session.CreateWindowAsync(
new NewWindowRequest { Name = "logs", Command = "/bin/sh" },
token);
// Type a command into the new pane and wait for what it prints.
await right.SendTextAsync(
"printf 'hello from %s\\n' tmux",
cancellationToken: token);
await TmuxWait.UntilAsync(
async cancellation => await right.CaptureAsync(
cancellationToken: cancellation),
output => output.Any(line => line.Contains("hello from tmux")),
TimeSpan.FromSeconds(10),
TimeSpan.FromMilliseconds(20),
token);
// Move the focus an attached client sees: the pane, then the window.
right = await right.SelectAsync(cancellationToken: token);
logs = await logs.SelectAsync(token);
// Walk the objects: down from the server, then up from one pane.
Server snapshot = await server.CaptureSnapshotAsync(
cancellationToken: token);
var sessions = snapshot.Sessions;
foreach (var each in sessions)
{
Console.WriteLine("session " + each.Name);
var windows = each.Windows;
foreach (var placed in windows)
{
var panes = placed.Panes;
Console.WriteLine(
$" window {placed.Index}:{placed.Name}: "
+ string.Join(" ", panes.Select(pane => pane.Id)));
}
}
Pane found = snapshot.Panes.Single(pane => pane.Id == right.Id);
Window window = found.Window;
Session owner = window.Session;
Console.WriteLine(
$"{found.Id} is in window {window.Name} of session {owner.Name}");
using System;
using System.Linq;
using System.Threading;
using System.Runtime.Versioning;
using LibTmux;
[assembly: UnsupportedOSPlatform("windows")]
if (OperatingSystem.IsWindows())
{
throw new PlatformNotSupportedException(
"This example requires tmux on Unix.");
}
using var deadline = new CancellationTokenSource(
TimeSpan.FromSeconds(30));
var token = deadline.Token;
// 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.
var options = new ServerConnectionOptions
{
SocketName = "quickstart-" + Guid.NewGuid().ToString("N"),
ConfigurationFile = "/dev/null",
TmuxBinaryPath = Environment.GetEnvironmentVariable("LIBTMUX_TMUX")
?? "tmux",
};
var owned = await Server.CreateOwnedAsync(options, token);
Server server = owned.Value;
try
{
Session session = await server.CreateSessionAsync(
new NewSessionRequest { Name = "demo", Command = "/bin/sh" },
token);
// Lay out the session: name its window, split it, add a second window.
// Neither the split nor the new window takes the focus.
Window editor = (await session.GetWindowsAsync(token))[0];
editor = await editor.RenameAsync("editor", token);
Pane left = await editor.GetActivePaneAsync(token);
Pane right = await left.SplitAsync(
new SplitPaneRequest
{
Direction = PaneDirection.Right,
Command = "/bin/sh",
},
token);
Window logs = await session.CreateWindowAsync(
new NewWindowRequest { Name = "logs", Command = "/bin/sh" },
token);
// Type a command into the new pane and wait for what it prints.
await right.SendTextAsync(
"printf 'hello from %s\\n' tmux",
cancellationToken: token);
await TmuxWait.UntilAsync(
async cancellation => await right.CaptureAsync(
cancellationToken: cancellation),
output => output.Any(line => line.Contains("hello from tmux")),
TimeSpan.FromSeconds(10),
TimeSpan.FromMilliseconds(20),
token);
// Move the focus an attached client sees: the pane, then the window.
right = await right.SelectAsync(cancellationToken: token);
logs = await logs.SelectAsync(token);
// Walk the objects: down from the server, then up from one pane.
Server snapshot = await server.CaptureSnapshotAsync(
cancellationToken: token);
var sessions = snapshot.Sessions;
foreach (var each in sessions)
{
Console.WriteLine("session " + each.Name);
var windows = each.Windows;
foreach (var placed in windows)
{
var panes = placed.Panes;
Console.WriteLine(
$" window {placed.Index}:{placed.Name}: "
+ string.Join(" ", panes.Select(pane => pane.Id)));
}
}
Pane found = snapshot.Panes.Single(pane => pane.Id == right.Id);
Window window = found.Window;
Session owner = window.Session;
Console.WriteLine(
$"{found.Id} is in window {window.Name} of session {owner.Name}");
}
catch (Exception error)
{
throw new InvalidOperationException(
"tmux quickstart failed", error);
}
using System;
using System.Linq;
using System.Threading;
using System.Runtime.Versioning;
using LibTmux;
[assembly: UnsupportedOSPlatform("windows")]
if (OperatingSystem.IsWindows())
{
throw new PlatformNotSupportedException(
"This example requires tmux on Unix.");
}
using var deadline = new CancellationTokenSource(
TimeSpan.FromSeconds(30));
var token = deadline.Token;
// 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.
var options = new ServerConnectionOptions
{
SocketName = "quickstart-" + Guid.NewGuid().ToString("N"),
ConfigurationFile = "/dev/null",
TmuxBinaryPath = Environment.GetEnvironmentVariable("LIBTMUX_TMUX")
?? "tmux",
};
await using var owned = await Server.CreateOwnedAsync(options, token);
Server server = owned.Value;
Session session = await server.CreateSessionAsync(
new NewSessionRequest { Name = "demo", Command = "/bin/sh" },
token);
// Lay out the session: name its window, split it, add a second window.
// Neither the split nor the new window takes the focus.
Window editor = (await session.GetWindowsAsync(token))[0];
editor = await editor.RenameAsync("editor", token);
Pane left = await editor.GetActivePaneAsync(token);
Pane right = await left.SplitAsync(
new SplitPaneRequest
{
Direction = PaneDirection.Right,
Command = "/bin/sh",
},
token);
Window logs = await session.CreateWindowAsync(
new NewWindowRequest { Name = "logs", Command = "/bin/sh" },
token);
// Type a command into the new pane and wait for what it prints.
await right.SendTextAsync(
"printf 'hello from %s\\n' tmux",
cancellationToken: token);
await TmuxWait.UntilAsync(
async cancellation => await right.CaptureAsync(
cancellationToken: cancellation),
output => output.Any(line => line.Contains("hello from tmux")),
TimeSpan.FromSeconds(10),
TimeSpan.FromMilliseconds(20),
token);
// Move the focus an attached client sees: the pane, then the window.
right = await right.SelectAsync(cancellationToken: token);
logs = await logs.SelectAsync(token);
// Walk the objects: down from the server, then up from one pane.
Server snapshot = await server.CaptureSnapshotAsync(
cancellationToken: token);
var sessions = snapshot.Sessions;
foreach (var each in sessions)
{
Console.WriteLine("session " + each.Name);
var windows = each.Windows;
foreach (var placed in windows)
{
var panes = placed.Panes;
Console.WriteLine(
$" window {placed.Index}:{placed.Name}: "
+ string.Join(" ", panes.Select(pane => pane.Id)));
}
}
Pane found = snapshot.Panes.Single(pane => pane.Id == right.Id);
Window window = found.Window;
Session owner = window.Session;
Console.WriteLine(
$"{found.Id} is in window {window.Name} of session {owner.Name}");
using System;
using System.Linq;
using System.Threading;
using System.Runtime.Versioning;
using LibTmux;
[assembly: UnsupportedOSPlatform("windows")]
if (OperatingSystem.IsWindows())
{
throw new PlatformNotSupportedException(
"This example requires tmux on Unix.");
}
using var deadline = new CancellationTokenSource(
TimeSpan.FromSeconds(30));
var token = deadline.Token;
// 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.
var options = new ServerConnectionOptions
{
SocketName = "quickstart-" + Guid.NewGuid().ToString("N"),
ConfigurationFile = "/dev/null",
TmuxBinaryPath = Environment.GetEnvironmentVariable("LIBTMUX_TMUX")
?? "tmux",
};
await using var owned = await Server.CreateOwnedAsync(options, token);
Server server = owned.Value;
try
{
Session session = await server.CreateSessionAsync(
new NewSessionRequest { Name = "demo", Command = "/bin/sh" },
token);
// Lay out the session: name its window, split it, add a second window.
// Neither the split nor the new window takes the focus.
Window editor = (await session.GetWindowsAsync(token))[0];
editor = await editor.RenameAsync("editor", token);
Pane left = await editor.GetActivePaneAsync(token);
Pane right = await left.SplitAsync(
new SplitPaneRequest
{
Direction = PaneDirection.Right,
Command = "/bin/sh",
},
token);
Window logs = await session.CreateWindowAsync(
new NewWindowRequest { Name = "logs", Command = "/bin/sh" },
token);
// Type a command into the new pane and wait for what it prints.
await right.SendTextAsync(
"printf 'hello from %s\\n' tmux",
cancellationToken: token);
await TmuxWait.UntilAsync(
async cancellation => await right.CaptureAsync(
cancellationToken: cancellation),
output => output.Any(line => line.Contains("hello from tmux")),
TimeSpan.FromSeconds(10),
TimeSpan.FromMilliseconds(20),
token);
// Move the focus an attached client sees: the pane, then the window.
right = await right.SelectAsync(cancellationToken: token);
logs = await logs.SelectAsync(token);
// Walk the objects: down from the server, then up from one pane.
Server snapshot = await server.CaptureSnapshotAsync(
cancellationToken: token);
var sessions = snapshot.Sessions;
foreach (var each in sessions)
{
Console.WriteLine("session " + each.Name);
var windows = each.Windows;
foreach (var placed in windows)
{
var panes = placed.Panes;
Console.WriteLine(
$" window {placed.Index}:{placed.Name}: "
+ string.Join(" ", panes.Select(pane => pane.Id)));
}
}
Pane found = snapshot.Panes.Single(pane => pane.Id == right.Id);
Window window = found.Window;
Session owner = window.Session;
Console.WriteLine(
$"{found.Id} is in window {window.Name} of session {owner.Name}");
}
catch (Exception error)
{
throw new InvalidOperationException(
"tmux quickstart failed", error);
}
Example details
No tmux server yet

tmux before the first call: no server is running.

No tmux server yet

tmux after Server.CreateOwnedAsync: no server is running.

%0 sh
[demo]

tmux after Server.CreateSessionAsync: added session demo.

%0 sh
[demo]

tmux after Session.GetWindowsAsync: unchanged.

%0 sh
[demo]

tmux after Window.RenameAsync: renamed window 0:sh to 0:editor.

%0 sh
[demo]

tmux after Window.GetActivePaneAsync: unchanged.

%0 sh
%1 sh
[demo]

tmux after Pane.SplitAsync: added pane %1 to window 0:editor.

%0 sh
%1 sh
[demo]

tmux after Session.CreateWindowAsync: added window 1:logs.

%0 sh
%1 sh
[demo]

tmux after Pane.SendTextAsync: sent keys to pane %1.

%0 sh
%1 sh
$ printf 'hello from %s\n' tmux
hello from tmux
$
[demo]

tmux after Pane.CaptureAsync: read pane %1.

%0 sh
%1 sh
$ printf 'hello from %s\n' tmux
hello from tmux
$
[demo]

tmux after Pane.SelectAsync: selected pane %1 in window 0:editor.

%2 sh
[demo]

tmux after Window.SelectAsync: selected window 1:logs.

%2 sh
[demo]

tmux after Server.CaptureSnapshotAsync: unchanged.

%2 sh
[demo]

tmux after Server.Sessions: unchanged, the call sent no command.

%2 sh
[demo]

tmux after Session.Windows: unchanged, the call sent no command.

%2 sh
[demo]

tmux after Window.Panes: unchanged, the call sent no command.

%2 sh
[demo]

tmux after Window.Panes: unchanged, the call sent no command.

%2 sh
[demo]

tmux after Server.Panes: unchanged, the call sent no command.

%2 sh
[demo]

tmux after Pane.Window: unchanged, the call sent no command.

%2 sh
[demo]

tmux after Window.Session: unchanged, the call sent no command.

No sessions

tmux after OwnedServerScope.DisposeAsync: the server has exited.

Before the first call

No tmux server is running yet.

Server.CreateOwnedAsync returned Task<OwnedServerScope>

{
"socketName": "quickstart-0123456789abcdef0123456789abcdef",
"configFile": "/dev/null"
}
3 tmux commands, 1 that changes tmux
  1. list-sessions error connecting to /tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdef (No such file or directory)
  2. start-server no output
  3. list-sessions no server running on /tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdef

Before these, the library asked tmux about itself 4 times (its version, its daemon, how a control client reads escapes).

Server.CreateSessionAsync returned Task<Session>

{
"id": "$0",
"name": "demo"
}
3 tmux commands, 2 that change tmux
  1. new-session -P -F '#{pid}:#{start_time} #{session_id} #{window_id} #{pane_id} #{window_index}' -d -s demo -- /bin/sh 3162114:1793888574 $0 @0 %0 0
  2. attach-session -f ignore-size,no-output,new-layouts no output
  3. display-message -p -t $0 #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window_ind… /dev/nullLT8f4639af840b4599b2362eLT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e1793888575LT8f4639a…

Before these, the library asked tmux about itself 2 times (its version, its daemon, how a control client reads escapes).

1 notification from tmux while the call ran
  1. %session-changed $0 demo

Session.GetWindowsAsync returned Task<IReadOnlyList<Window>>

{
"id": "@0",
"index": 0,
"name": "sh"
}
1 tmux command
  1. list-windows -t $0 -F #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window_index}… /dev/nullLT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e1793888575LT8f4639…

Window.RenameAsync returned Task<Window>

{
"id": "@0",
"index": 0,
"name": "editor"
}
2 tmux commands, 1 that changes tmux
  1. rename-window -t @0 -- editor no output
  2. display-message -p -t $0:0 #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window_i… /dev/nullLT8f4639af840b4599b2362eLT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e1793888575LT8f4639a…
1 notification from tmux while the call ran
  1. %window-renamed @0 editor

Window.GetActivePaneAsync returned Task<Pane>

{
"id": "%0"
}
1 tmux command
  1. list-panes -t $0:0 -f #{pane_active} -F #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{… /dev/nullLT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e1793888575LT8f4639…

Pane.SplitAsync returned Task<Pane>

{
"id": "%1"
}
2 tmux commands, 1 that changes tmux
  1. split-window -P -F #{pane_id} -t %0 -h -d -- /bin/sh %1
  2. display-message -p -t %1 #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window_ind… /dev/nullLT8f4639af840b4599b2362eLT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e1793888575LT8f4639a…
1 notification from tmux while the call ran
  1. %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"}]}} *

Session.CreateWindowAsync returned Task<Window>

{
"id": "@1",
"index": 1,
"name": "logs"
}
2 tmux commands, 1 that changes tmux
  1. new-window -P -F #{window_id} -d -t $0: -n logs -- /bin/sh @1
  2. list-windows -t $0 -F #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window_index}… /dev/nullLT8f4639af840b4599b2362e2LT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1793888575LT8f4639…
1 notification from tmux while the call ran
  1. %window-add @1

Pane.SendTextAsync returned Task

null
2 tmux commands, 2 that change tmux
  1. send-keys -t %1 -l -- 'printf '\''hello from %s\n'\'' tmux' no output
  2. send-keys -t %1 Enter no output

Pane.CaptureAsync returned Task<IReadOnlyList<string>>

[
"$ printf 'hello from %s\\n' tmux",
"hello from tmux",
"$"
]
1 tmux command
  1. capture-pane -t %1 -p $ printf 'hello from %s\n' tmux hello from tmux $

Pane.SelectAsync returned Task<Pane>

{
"id": "%1"
}
2 tmux commands, 1 that changes tmux
  1. select-pane -t %1 no output
  2. display-message -p -t $0:.%1 #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window… /dev/nullLT8f4639af840b4599b2362eLT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1793888575LT8f4639a…
1 notification from tmux while the call ran
  1. %window-pane-changed @0 %1

Window.SelectAsync returned Task<Window>

{
"id": "@1",
"index": 1,
"name": "logs"
}
2 tmux commands, 1 that changes tmux
  1. select-window -t @1 no output
  2. display-message -p -t $0:1 #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window_i… /dev/nullLT8f4639af840b4599b2362eLT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1793888575LT8f4639a…
1 notification from tmux while the call ran
  1. %session-window-changed $0 @1

Server.CaptureSnapshotAsync returned Task<Server>

{
"sessions": 1,
"windows": 2,
"panes": 3
}
3 tmux commands
  1. list-sessions -F #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window_index}LT8f4… /dev/nullLT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1793888575LT8f4639…
  2. list-windows -a -F #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window_index}LT8… /dev/nullLT8f4639af840b4599b2362e2LT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1793888575LT8f4639…
  3. list-panes -a -F #{config_files}LT8f4639af840b4599b2362e#{line}LT8f4639af840b4599b2362e#{next_session_id}LT8f4639af840b4599b2362e#{pid}LT8f4639af840b4599b2362e#{socket_path}LT8f4639af840b4599b2362e#{start_time}LT8f4639af840b4599b2362e#{uid}LT8f4639af840b4599b2362e#{user}LT8f4639af840b4599b2362e#{version}LT8f4639af840b4599b2362e#{active_window_index}LT8f4639af840b4599b2362e#{last_window_index}LT8f4… /dev/nullLT8f4639af840b4599b2362e2LT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1793888575LT8f4639…

Before these, the library asked tmux about itself 1 time (its version, its daemon, how a control client reads escapes).

Server.Sessions returned CapturedRelation<Session>

{
"sessions": [
"$0"
]
}

The call sent no tmux command.

Session.Windows returned CapturedRelation<Window>

{
"windows": [
"@0",
"@1"
]
}

The call sent no tmux command.

Window.Panes returned CapturedRelation<Pane>

{
"panes": [
"%0",
"%1"
]
}

The call sent no tmux command.

Window.Panes returned CapturedRelation<Pane>

{
"panes": [
"%2"
]
}

The call sent no tmux command.

Server.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.

Window.Session returned Session

{
"id": "$0",
"name": "demo"
}

The call sent no tmux command.

OwnedServerScope.DisposeAsync returned ValueTask

null
2 tmux commands, 1 that changes tmux
  1. display-message -p #{pid} 3162114
  2. kill-server no output

Before these, the library asked tmux about itself 1 time (its version, its daemon, how a control client reads escapes).

1 notification from tmux while the call ran
  1. %exit
0/19
Run this example

.NET SDK 10.0.303, .NET 8 and 10 runtimes, tmux on Linux/macOS

Save the program above as app/Program.cs 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.

app/Example.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>10-recommended</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<PackageReference Include="LibTmux" Version="[0.1.1]" />
</ItemGroup>
</Project>
app/global.json
{
"sdk": {
"version": "10.0.303",
"rollForward": "disable",
"allowPrerelease": false
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}

Setup and run

# Save the files above at their displayed relative paths.
cd app
dotnet restore Example.csproj
dotnet build Example.csproj -c Release --no-restore --warnaserror
export TMUX_TMPDIR=/tmp/libtmux-dotnet-dev
mkdir -p "$TMUX_TMPDIR"
unset TMUX TMUX_PANE
dotnet bin/Release/net8.0/Example.dll
dotnet bin/Release/net10.0/Example.dll

Expected output

session demo
window 0:editor: %0 %1
window 1:logs: %2
%1 is in window editor of session demo

Install LibTmux

$ dotnet package add LibTmux

.NET 10 SDK: run in your project directory. On .NET 8 or 9, use dotnet add package with the same arguments.

NuGet\Install-Package LibTmux -Version 0.1.1

Run in Visual Studio on Windows, in Tools > NuGet Package Manager > Package Manager Console. Choose the target project in that console.

<PackageReference Include="LibTmux" Version="0.1.1" />

Add this inside an ItemGroup in your .csproj or .fsproj, then run dotnet restore. For central version management, use the CPM tab.

Directory.Packages.props

<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
  </PropertyGroup>
  <ItemGroup>
    <PackageVersion Include="LibTmux" Version="0.1.1" />
  </ItemGroup>
</Project>

Project file (.csproj or .fsproj)

<PackageReference Include="LibTmux" />

Save Directory.Packages.props at the solution root, or merge these settings into the existing file. Add the versionless reference inside the project’s ItemGroup, then run dotnet restore.

$ paket add LibTmux --version 0.1.1 --interactive

Requires Paket and a solution initialized with paket init. The interactive prompt selects the projects that should reference the package.

#r "nuget: LibTmux, 0.1.1"

Use in an F# .fsx script, dotnet fsi, or a Polyglot Notebook with NuGet support, on .NET 8 or later. This is not a directive for an ordinary compiled project.

#:package LibTmux@0.1.1

C# file-based apps require the .NET 10 SDK. Place this at the top of a .cs file, before code, then run dotnet run app.cs. F# scripts use the Script & Interactive tab.

#addin nuget:?package=LibTmux&version=0.1.1&loaddependencies=true

Use Cake.Tool 6 or later for a .cake script on .NET 8 or later, with Cake’s in-process NuGet client enabled. This loads the library and its dependencies; it has no Cake task aliases or executable tool. Cake Frosting projects use PackageReference.

MCP

tmux through MCP

Replay Hover a call to preview the tmux state after it. Click to pin it.

tmux before the first call.

tmux window of 1 pane
%0 sh
[checks] 0:sh*

tmux after create_session.

tmux window of 2 panes
%0 sh
%1 sh
[checks] 0:sh*

tmux after split_window.

tmux window of 2 panes
%0 sh
%1 sh
[checks] 0:sh*

tmux after list_windows: unchanged, the call only reads.

tmux window of 2 panes
%0 sh
$ pytest -q
..                               [100%]
2 passed in 0.00s
%1 sh
[checks] 0:sh*

tmux after run_shell_command.

tmux window of 2 panes
%0 sh
$ pytest -q
..                               [100%]
2 passed in 0.00s
%1 sh
$ cat checks.log
2026-01-01 checks started
2026-01-01 checks finished
[checks] 0:sh*

tmux after run_shell_command.

No sessions

tmux after kill_session.

you

Create a tmux session called checks, split its window into two panes, run pytest -q in one and show checks.log in the other, show me the results, then remove the session.

agentCreate the session.

create_session Execute {"name":"checks"}
Result
{
"changed": "Created session $0.",
"paneId": "%0",
"windowId": "@0",
"sessionId": "$0"
}

agentSplit the pane the create result returned (%0) in two.

split_window Execute {"paneId":"%0","direction":"Right"}
Result
{
"changed": "Split %0; the new pane is %1.",
"paneId": "%1",
"windowId": "@0",
"sessionId": "$0"
}

agentRead the window's layout.

list_windows Inspect {"session":"checks"}
Result
{
"result": [
{
"windowId": "@0",
"sessionId": "$0",
"index": 0,
"name": "sh",
"width": 80,
"height": 24,
"active": true,
"paneCount": 2,
"layout": "{\"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\"}]}}"
}
]
}

agentRun the tests in the pane the create result returned (%0).

run_shell_command Execute {"paneId":"%0","command":"pytest -q"}
Result
{
"paneId": "%0",
"exitStatus": 0,
"timedOut": false,
"output": {
"lines": [
".. [100%]",
"2 passed in 0.00s"
],
"truncated": false,
"droppedLines": 0,
"droppedBytes": 0
},
"elapsedSeconds": 0.292,
"effectiveTimeoutSeconds": 30,
"linesMissed": false,
"anchorLost": false,
"started": true,
"paneExited": false
}

agentShow the log in the new pane the split returned (%1).

run_shell_command Execute {"paneId":"%1","command":"cat checks.log"}
Result
{
"paneId": "%1",
"exitStatus": 0,
"timedOut": false,
"output": {
"lines": [
"2026-01-01 checks started",
"2026-01-01 checks finished"
],
"truncated": false,
"droppedLines": 0,
"droppedBytes": 0
},
"elapsedSeconds": 0.014,
"effectiveTimeoutSeconds": 30,
"linesMissed": false,
"anchorLost": false,
"started": true,
"paneExited": false
}

agentRemove the session once the result is read.

kill_session Teardown {"session":"checks"}
Result
{
"changed": "Killed session $0.",
"paneId": null,
"windowId": null,
"sessionId": "$0"
}

agent in %0 it printed 2 passed in 0.00s; in %1 it printed 2026-01-01 checks finished.

0/6

Install LibTmux.Mcp

Choose your client and configuration scope, then run the command or paste the configuration.

$ claude mcp add tmux -- dnx LibTmux.Mcp --yes

Runs 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 --yes

Runs 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 --yes

Runs 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.Mcp

Then register:

$ claude mcp add tmux -- libtmux-mcp

Installs the `libtmux-mcp` tool from NuGet.

Config file: ~/.claude.json (this project)

Build or install the server first:

$ dotnet tool install --global LibTmux.Mcp

Then register:

$ claude mcp add tmux --scope user -- libtmux-mcp

Installs the `libtmux-mcp` tool from NuGet.

Config file: ~/.claude.json (all projects)

Build or install the server first:

$ dotnet tool install --global LibTmux.Mcp

Then register:

$ claude mcp add tmux --scope project -- libtmux-mcp

Installs the `libtmux-mcp` tool from NuGet.

Config file: .mcp.json (in repo, version-controlled)

{
    "mcpServers": {
        "tmux": {
            "command": "dnx",
            "args": ["LibTmux.Mcp", "--yes"]
        }
    }
}

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.Mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

Installs the `libtmux-mcp` tool from NuGet.

Config file: claude_desktop_config.json

$ codex mcp add tmux -- dnx LibTmux.Mcp --yes

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

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

[mcp_servers.tmux]
command = "dnx"
args = ["LibTmux.Mcp", "--yes"]

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.Mcp

Then register:

$ codex mcp add tmux -- libtmux-mcp

Installs the `libtmux-mcp` tool from NuGet.

Config file: ~/.codex/config.toml

Build or install the server first:

$ dotnet tool install --global LibTmux.Mcp

Then register:

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

[mcp_servers.tmux]
command = "libtmux-mcp"

Installs the `libtmux-mcp` tool from NuGet.

Config file: .codex/config.toml (in repo)

$ gemini mcp add --scope user tmux dnx -- LibTmux.Mcp --yes

Runs 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 --yes

Runs 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.Mcp

Then register:

$ gemini mcp add --scope user tmux libtmux-mcp

Installs the `libtmux-mcp` tool from NuGet.

Config file: ~/.gemini/settings.json

Build or install the server first:

$ dotnet tool install --global LibTmux.Mcp

Then register:

$ gemini mcp add --scope project tmux libtmux-mcp

Installs the `libtmux-mcp` tool from NuGet.

Config file: .gemini/settings.json (in repo)

{
    "mcpServers": {
        "tmux": {
            "command": "dnx",
            "args": ["LibTmux.Mcp", "--yes"]
        }
    }
}

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)

{
    "mcpServers": {
        "tmux": {
            "command": "dnx",
            "args": ["LibTmux.Mcp", "--yes"]
        }
    }
}

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.Mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

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.Mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

Installs the `libtmux-mcp` tool from NuGet.

Config file: ~/.cursor/mcp.json

$ grok mcp add --scope user tmux -- dnx LibTmux.Mcp --yes

Runs 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 --yes

Runs 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.Mcp

Then register:

$ grok mcp add --scope user tmux -- libtmux-mcp

Installs the `libtmux-mcp` tool from NuGet.

Config file: ~/.grok/config.toml

Build or install the server first:

$ dotnet tool install --global LibTmux.Mcp

Then register:

$ grok mcp add --scope project tmux -- libtmux-mcp

Installs the `libtmux-mcp` tool from NuGet.

Config file: ./.grok/config.toml (in repo)

{
    "mcpServers": {
        "tmux": {
            "command": "dnx",
            "args": ["LibTmux.Mcp", "--yes"]
        }
    }
}

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.Mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

Installs the `libtmux-mcp` tool from NuGet.

Config file: ~/.gemini/config/mcp_config.json

$ opencode mcp add tmux -- dnx LibTmux.Mcp --yes

Runs 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.Mcp

Then register:

$ opencode mcp add tmux -- libtmux-mcp

Installs the `libtmux-mcp` tool from NuGet.

Config file: ~/.config/opencode/opencode.jsonc

Embed the server in a program
examples/LibTmux.Examples/Snippets/Mcp.cs
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

Preset
Two panesShort-hand panesThree panesFour panesMain-horizontal layoutEnvironmentStart directorySynchronized panesBlank panesVariables in valuesFocusMain pane height as a percentageMinimal workspacetmux optionsShell per paneSkip Enter for a commandSkip Enter for a panePause around a commandPause before a paneWait for a virtualenvKeep commands out of historyWindow index

Choose a preset 22

Two panes

A window of two panes.

session_name: myproject
start_directory: ~/code/myproject
windows:
- window_name: editor
layout: main-vertical
panes:
- vim
- git status
- window_name: server
panes:
- npm run dev
{
"session_name": "myproject",
"start_directory": "~/code/myproject",
"windows": [
{
"window_name": "editor",
"layout": "main-vertical",
"panes": [
"vim",
"git status"
]
},
{
"window_name": "server",
"panes": [
"npm run dev"
]
}
]
}
Window 0, editor: 2 panes, main-vertical❯ vim❯ git status
layout main-vertical
Window 1, server: 1 pane, even-vertical❯ npm run dev
no layout set

Save the file as workspace.yaml and load it with:

tmux-workspace load workspace.yaml

Workspace file: src/LibTmux.Workspace.Cli/README.md. Tested by The_quickstart_workspace_builds_what_the_readme_describes (tests/LibTmux.Workspace.Cli.Tests/ReadmeCommandTests.cs; 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: 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'
{
"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'"
]
}
]
}
Window 0, long form: 3 panes, even-vertical❯ echo 'did you know'❯ echo 'you can inline'❯ echo 'single commands'❯ echo 'for panes'
no layout set

Workspace file: tests/Fixtures/tmuxp/shorthands.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Three panes

A window of three panes.

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
{
"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"
]
}
]
}
Window 0, dev window: 3 panes, main-vertical❯ cd /var/log❯ ls -al | grep \.log❯ echo hello❯ echo hello
layout main-vertical

Workspace file: tests/Fixtures/tmuxp/3-pane.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Four panes

A window of four panes.

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
{
"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"
]
}
]
}
Window 0, dev window: 4 panes, tiled❯ cd /var/log❯ ls -al | grep \.log❯ echo hello❯ echo hello❯ echo hello
layout tiled

Workspace file: tests/Fixtures/tmuxp/4-pane.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Main-horizontal layout

The main-horizontal layout gives the first pane the top of the window and splits the rest below it.

session_name: main-pane-height
start_directory: "~"
windows:
- layout: main-horizontal
options:
main-pane-height: 30
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": 30
},
"panes": [
{
"shell_command": [
"top"
],
"start_directory": "~"
},
{
"shell_command": [
"echo \"hey\""
]
},
{
"shell_command": [
"echo \"moo\""
]
}
],
"window_name": "my window name"
}
]
}
Window 0, my window name: 3 panes, main-horizontal❯ top❯ echo "hey"❯ echo "moo"
layout main-horizontal

Workspace file: tests/Fixtures/tmuxp/main-pane-height.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Environment

environment sets variables for a session, a window or a pane.

session_name: Environment variables test
environment:
EDITOR: /usr/bin/vim
DJANGO_SETTINGS_MODULE: my_app.settings.local
SERVER_PORT: "8009"
windows:
- window_name: Django project
panes:
- ./manage.py runserver 0.0.0.0:${SERVER_PORT}
- window_name: Another Django project
environment:
DJANGO_SETTINGS_MODULE: my_app.settings.local
SERVER_PORT: "8010"
panes:
- ./manage.py runserver 0.0.0.0:${SERVER_PORT}
- environment:
DJANGO_SETTINGS_MODULE: my_app.settings.local-testing
SERVER_PORT: "8011"
shell_command: ./manage.py runserver 0.0.0.0:${SERVER_PORT}
{
"session_name": "Environment variables test",
"environment": {
"EDITOR": "/usr/bin/vim",
"DJANGO_SETTINGS_MODULE": "my_app.settings.local",
"SERVER_PORT": "8009"
},
"windows": [
{
"window_name": "Django project",
"panes": [
"./manage.py runserver 0.0.0.0:${SERVER_PORT}"
]
},
{
"window_name": "Another Django project",
"environment": {
"DJANGO_SETTINGS_MODULE": "my_app.settings.local",
"SERVER_PORT": "8010"
},
"panes": [
"./manage.py runserver 0.0.0.0:${SERVER_PORT}",
{
"environment": {
"DJANGO_SETTINGS_MODULE": "my_app.settings.local-testing",
"SERVER_PORT": "8011"
},
"shell_command": "./manage.py runserver 0.0.0.0:${SERVER_PORT}"
}
]
}
]
}
Window 0, Django project: 1 pane, even-vertical❯ ./manage.py runserver 0.0.0.0:${SERVER_PORT}
no layout set
Window 1, Another Django project: 2 panes, even-vertical❯ ./manage.py runserver 0.0.0.0:${SERVER_PORT}❯ ./manage.py runserver 0.0.0.0:${SERVER_PORT}
no layout set

Workspace file: tests/Fixtures/tmuxp/session-environment.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Start directory

start_directory chooses where a session, a window or a pane starts.

session_name: start directory
start_directory: /var/
windows:
- window_name: should be /var/
panes:
- shell_command:
- echo "\033c
- it trickles down from session-level"
- echo hello
- window_name: should be /var/log
start_directory: log
panes:
- shell_command:
- echo '\033c
- window start_directory concatenates to session start_directory
- if it is not absolute'
- echo hello
- window_name: should be ~
start_directory: "~"
panes:
- shell_command:
- 'echo \\033c ~ has precedence. note: remember to quote ~ in YAML'
- echo hello
- window_name: should be /bin
start_directory: /bin
panes:
- echo '\033c absolute paths also have precedence.'
- echo hello
- window_name: should be workspace file's dir
start_directory: ./
panes:
- shell_command:
- echo '\033c
- ./ is relative to workspace file location
- ../ will be parent of workspace file
- ./test will be \"test\" dir inside dir of workspace file'
- shell_command:
- echo '\033c
- This way you can load up workspaces from projects and maintain
- relative paths.'
{
"session_name": "start directory",
"start_directory": "/var/",
"windows": [
{
"window_name": "should be /var/",
"panes": [
{
"shell_command": [
"echo \"\\033c",
"it trickles down from session-level\""
]
},
"echo hello"
]
},
{
"window_name": "should be /var/log",
"start_directory": "log",
"panes": [
{
"shell_command": [
"echo '\\033c",
"window start_directory concatenates to session start_directory",
"if it is not absolute'"
]
},
"echo hello"
]
},
{
"window_name": "should be ~",
"start_directory": "~",
"panes": [
{
"shell_command": [
"echo \\\\033c ~ has precedence. note: remember to quote ~ in YAML"
]
},
"echo hello"
]
},
{
"window_name": "should be /bin",
"start_directory": "/bin",
"panes": [
"echo '\\033c absolute paths also have precedence.'",
"echo hello"
]
},
{
"window_name": "should be workspace file's dir",
"start_directory": "./",
"panes": [
{
"shell_command": [
"echo '\\033c",
"./ is relative to workspace file location",
"../ will be parent of workspace file",
"./test will be \\\"test\\\" dir inside dir of workspace file'"
]
},
{
"shell_command": [
"echo '\\033c",
"This way you can load up workspaces from projects and maintain",
"relative paths.'"
]
}
]
}
]
}
Window 0, should be /var/: 2 panes, even-vertical❯ echo "\033c❯ it trickles down from session-level"❯ echo hello
no layout set
Window 1, should be /var/log: 2 panes, even-vertical❯ echo '\033c❯ window start_directory concatenates to session start_directory❯ if it is not absolute'❯ echo hello
no layout set
Window 2, should be ~: 2 panes, even-vertical❯ echo \\033c ~ has precedence. note: remember to quote ~ in YAML❯ echo hello
no layout set
Window 3, should be /bin: 2 panes, even-vertical❯ echo '\033c absolute paths also have precedence.'❯ echo hello
no layout set
Window 4, should be workspace file's dir: 2 panes, even-vertical❯ echo '\033c❯ ./ is relative to workspace file location❯ ../ will be parent of workspace file❯ ./test will be \"test\" dir inside dir of workspace file'❯ echo '\033c❯ This way you can load up workspaces from projects and maintain❯ relative paths.'
no layout set

Workspace file: tests/Fixtures/tmuxp/start-directory.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Synchronized panes

options_after sets synchronize-panes once the panes exist, so typing in one pane reaches the others.

session_name: 2-pane-synchronized
windows:
- 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"
}
}
]
}
Window 0, Two synchronized panes: 2 panes, even-vertical❯ ssh server1❯ ssh server2
no layout set

Workspace file: tests/Fixtures/tmuxp/2-pane-synchronized.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Blank panes

An empty entry, null, pane or blank opens a pane with no command.

session_name: Blank pane test
windows:
# Emptiness will simply open a blank pane, if no shell_command_before.
# All these are equivalent
- window_name: Blank pane test
panes:
-
- pane
- blank
- window_name: More blank panes
panes:
- null
- shell_command:
- shell_command:
-
# an empty string will be treated as a carriage return
- window_name: Empty string (return)
panes:
- ""
- shell_command: ""
- shell_command:
- ""
# a pane can have other options but still be blank
- window_name: Blank with options
panes:
- focus: true
- start_directory: /tmp
{
"session_name": "Blank pane test",
"windows": [
{
"window_name": "Blank pane test",
"panes": [
null,
"pane",
"blank"
]
},
{
"window_name": "More blank panes",
"panes": [
null,
{
"shell_command": null
},
{
"shell_command": [
null
]
}
]
},
{
"window_name": "Empty string (return)",
"panes": [
"",
{
"shell_command": ""
},
{
"shell_command": [
""
]
}
]
},
{
"window_name": "Blank with options",
"panes": [
{
"focus": true
},
{
"start_directory": "/tmp"
}
]
}
]
}
Window 0, Blank pane test: 3 panes, even-vertical
no layout set
Window 1, More blank panes: 3 panes, even-vertical
no layout set
Window 2, Empty string (return): 3 panes, even-vertical
no layout set
Window 3, Blank with options: 2 panes, even-vertical
no layout set

Workspace file: tests/Fixtures/tmuxp/blank-panes.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Variables in values

A ${VAR} in a name, a path or an option expands from the environment of the loading process.

start_directory: "${PWD}/test"
shell_command_before: "echo ${PWD}"
before_script: "${MY_ENV_VAR}/test3.sh"
session_name: session - ${USER} (${MY_ENV_VAR})
windows:
- window_name: editor
panes:
- shell_command:
- tail -F /var/log/syslog
start_directory: /var/log
- window_name: logging for ${USER}
options:
automatic-rename: true
panes:
- shell_command:
- htop
- ls $PWD
{
"start_directory": "${PWD}/test",
"shell_command_before": "echo ${PWD}",
"before_script": "${MY_ENV_VAR}/test3.sh",
"session_name": "session - ${USER} (${MY_ENV_VAR})",
"windows": [
{
"window_name": "editor",
"panes": [
{
"shell_command": [
"tail -F /var/log/syslog"
]
}
],
"start_directory": "/var/log"
},
{
"window_name": "logging for ${USER}",
"options": {
"automatic-rename": true
},
"panes": [
{
"shell_command": [
"htop",
"ls $PWD"
]
}
]
}
]
}
Window 0, editor: 1 pane, even-vertical❯ tail -F /var/log/syslog
no layout set
Window 1, logging for ${USER}: 1 pane, even-vertical❯ htop❯ ls $PWD
no layout set

Workspace file: tests/Fixtures/tmuxp/env-variables.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Focus

focus: true selects a window or a pane when the session is built.

session_name: focus
windows:
- window_name: attached window
focus: true
panes:
- shell_command:
- echo hello
- echo 'this pane should be selected on load'
focus: true
- shell_command:
- cd /var/log
- echo hello
- window_name: second window
shell_command_before: cd /var/log
panes:
- pane
- shell_command:
- echo 'this pane should be focused, when window switched to first time'
focus: true
- pane
{
"session_name": "focus",
"windows": [
{
"window_name": "attached window",
"focus": true,
"panes": [
{
"shell_command": [
"echo hello",
"echo 'this pane should be selected on load'"
],
"focus": true
},
{
"shell_command": [
"cd /var/log",
"echo hello"
]
}
]
},
{
"window_name": "second window",
"shell_command_before": "cd /var/log",
"panes": [
"pane",
{
"shell_command": [
"echo 'this pane should be focused, when window switched to first time'"
],
"focus": true
},
"pane"
]
}
]
}
Window 0, attached window: 2 panes, even-vertical❯ echo hello❯ echo 'this pane should be selected on load'❯ cd /var/log❯ echo hello
no layout set
Window 1, second window: 3 panes, even-vertical❯ echo 'this pane should be focused, when window switched to first time'
no layout set

Workspace file: tests/Fixtures/tmuxp/focus-window-and-panes.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed 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-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
{
"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"
}
]
}
Window 0, my window name: 3 panes, main-horizontal❯ top❯ echo "hey"❯ echo "moo"
layout main-horizontal

Workspace file: tests/Fixtures/tmuxp/main-pane-height-percentage.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed 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 session
windows:
- panes:
-
{
"session_name": "My tmux session",
"windows": [
{
"panes": [
null
]
}
]
}
Window 0: 1 pane, even-vertical
no layout set

Workspace file: tests/Fixtures/tmuxp/minimal.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed 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 options
start_directory: "~"
global_options:
default-shell: /bin/sh
default-command: /bin/sh
options:
main-pane-height: ${MAIN_PANE_HEIGHT} # works with env variables
windows:
- 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\""
]
}
]
}
]
}
Window 0: 3 panes, main-horizontal❯ man echo❯ echo "hey"❯ echo "moo"
layout main-horizontal

Workspace file: tests/Fixtures/tmuxp/options.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Shell per pane

A pane can start its own shell or program, and window_shell sets the default for a window.

session_name: Pane shell example
windows:
- window_name: first
window_shell: /usr/bin/python2
layout: even-vertical
suppress_history: false
options:
remain-on-exit: true
panes:
- shell: /usr/bin/python3
shell_command:
- print('This is python 3')
- shell: /usr/bin/vim -u none
shell_command:
- iAll panes have the `remain-on-exit` setting on.
- When you exit out of the shell or application, the panes will remain.
- Use tmux command `:kill-pane` to remove the pane.
- Use tmux command `:respawn-pane` to restart the shell in the pane.
- Use <Escape> and then `:q!` to get out of this vim window. :-)
- shell_command:
- print('Hello World 2')
- shell: /usr/bin/top
{
"session_name": "Pane shell example",
"windows": [
{
"window_name": "first",
"window_shell": "/usr/bin/python2",
"layout": "even-vertical",
"suppress_history": false,
"options": {
"remain-on-exit": true
},
"panes": [
{
"shell": "/usr/bin/python3",
"shell_command": [
"print('This is python 3')"
]
},
{
"shell": "/usr/bin/vim -u none",
"shell_command": [
"iAll panes have the `remain-on-exit` setting on.",
"When you exit out of the shell or application, the panes will remain.",
"Use tmux command `:kill-pane` to remove the pane.",
"Use tmux command `:respawn-pane` to restart the shell in the pane.",
"Use <Escape> and then `:q!` to get out of this vim window. :-)"
]
},
{
"shell_command": [
"print('Hello World 2')"
]
},
{
"shell": "/usr/bin/top"
}
]
}
]
}
Window 0, first: 4 panes, even-vertical❯ print('This is python 3')❯ iAll panes have the `remain-on-exit` setting on.❯ When you exit out of the shell or application, the panes will remain.❯ Use tmux command `:kill-pane` to remove the pane.❯ Use tmux command `:respawn-pane` to restart the shell in the pane.❯ Use <Escape> and then `:q!` to get out of this vim window. :-)❯ print('Hello World 2')
layout even-vertical

Workspace file: tests/Fixtures/tmuxp/pane-shell.yaml. Tested by Every_tmuxp_example_loads_through_the_commands_own_loader (tests/LibTmux.Workspace.Cli.Tests/ContractTests.cs; 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
}
]
}
]
}
]
}
Window 0: 1 pane, even-vertical❯ echo "___$((11 + 1))___"❯ echo "___$((1 + 3))___"
no layout set

Workspace file: tests/Fixtures/tmuxp/skip-send.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed 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
}
]
}
]
}
Window 0: 2 panes, even-vertical❯ echo "___$((1 + 3))___"❯ echo "___$((1 + 3))___"\;❯ echo "___$((1 + 3))___"
no layout set

Workspace file: tests/Fixtures/tmuxp/skip-send-pane-level.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Pause around a command

sleep_before and sleep_after delay a command or the one after it.

session_name: Pause / skip command execution (command-level)
windows:
- panes:
- shell_command:
# Executes immediately
- echo "___$((11 + 1))___"
# Delays before sending 2 seconds
- cmd: echo "___$((1 + 3))___"
sleep_before: 2
# Executes immediately
- cmd: echo "___$((1 + 3))___"
# Pauses 2 seconds after
- cmd: echo "Stuff rendering here!"
sleep_after: 2
# Executes after earlier commands (after 2 sec)
- cmd: echo "2 seconds later"
{
"session_name": "Pause / skip command execution (command-level)",
"windows": [
{
"panes": [
{
"shell_command": [
"echo \"___$((11 + 1))___\"",
{
"cmd": "echo \"___$((1 + 3))___\"",
"sleep_before": 2
},
{
"cmd": "echo \"___$((1 + 3))___\""
},
{
"cmd": "echo \"Stuff rendering here!\"",
"sleep_after": 2
},
{
"cmd": "echo \"2 seconds later\""
}
]
}
]
}
]
}
Window 0: 1 pane, even-vertical❯ echo "___$((11 + 1))___"❯ echo "___$((1 + 3))___"❯ echo "___$((1 + 3))___"❯ echo "Stuff rendering here!"❯ echo "2 seconds later"
no layout set

Workspace file: tests/Fixtures/tmuxp/sleep.yaml. Tested by Every_tmuxp_example_loads_through_the_commands_own_loader (tests/LibTmux.Workspace.Cli.Tests/ContractTests.cs; loaded by the library in a test; the command is not run).

Pause before a pane

sleep_before on a pane waits before it sends any of its commands.

session_name: Pause / skip command execution (pane-level)
windows:
- panes:
- # Wait 2 seconds before sending all commands in this pane
sleep_before: 2
shell_command:
- echo "___$((11 + 1))___"
- cmd: echo "___$((1 + 3))___"
- cmd: echo "___$((1 + 3))___"
- cmd: echo "Stuff rendering here!"
- cmd: echo "2 seconds later"
{
"session_name": "Pause / skip command execution (pane-level)",
"windows": [
{
"panes": [
{
"sleep_before": 2,
"shell_command": [
"echo \"___$((11 + 1))___\"",
{
"cmd": "echo \"___$((1 + 3))___\""
},
{
"cmd": "echo \"___$((1 + 3))___\""
},
{
"cmd": "echo \"Stuff rendering here!\""
},
{
"cmd": "echo \"2 seconds later\""
}
]
}
]
}
]
}
Window 0: 1 pane, even-vertical❯ echo "___$((11 + 1))___"❯ echo "___$((1 + 3))___"❯ echo "___$((1 + 3))___"❯ echo "Stuff rendering here!"❯ echo "2 seconds later"
no layout set

Workspace file: tests/Fixtures/tmuxp/sleep-pane-level.yaml. Tested by Every_tmuxp_example_loads_through_the_commands_own_loader (tests/LibTmux.Workspace.Cli.Tests/ContractTests.cs; loaded by the library in a test; the command is not run).

Wait for a virtualenv

A setup command with sleep_before and sleep_after gives a virtualenv time to activate before the commands run.

session_name: virtualenv
shell_command_before:
# - cmd: source $(poetry env info --path)/bin/activate
# - cmd: source `pipenv --venv`/bin/activate
- cmd: source .venv/bin/activate
sleep_before: 1
sleep_after: 1
windows:
- panes:
- shell_command:
- ./manage.py runserver
{
"session_name": "virtualenv",
"shell_command_before": [
{
"cmd": "source .venv/bin/activate",
"sleep_before": 1,
"sleep_after": 1
}
],
"windows": [
{
"panes": [
{
"shell_command": [
"./manage.py runserver"
]
}
]
}
]
}
Window 0: 1 pane, even-vertical❯ ./manage.py runserver
no layout set

Workspace file: tests/Fixtures/tmuxp/sleep-virtualenv.yaml. Tested by Every_tmuxp_example_loads_through_the_commands_own_loader (tests/LibTmux.Workspace.Cli.Tests/ContractTests.cs; loaded by the library in a test; the command is not run).

Keep commands out of history

suppress_history chooses whether commands reach the shell history, per session, window, pane or command.

session_name: suppress
suppress_history: false
windows:
- window_name: appended
focus: true
suppress_history: false
panes:
- echo "window in the history!"
- window_name: suppressed
suppress_history: true
panes:
- echo "window not in the history!"
- window_name: default
panes:
- echo "session in the history!"
- window_name: mixed
suppress_history: false
panes:
- shell_command:
- echo "command in the history!"
suppress_history: false
- shell_command:
- echo "command not in the history!"
suppress_history: true
- shell_command:
- echo "window in the history!"
{
"session_name": "suppress",
"suppress_history": false,
"windows": [
{
"window_name": "appended",
"focus": true,
"suppress_history": false,
"panes": [
"echo \"window in the history!\""
]
},
{
"window_name": "suppressed",
"suppress_history": true,
"panes": [
"echo \"window not in the history!\""
]
},
{
"window_name": "default",
"panes": [
"echo \"session in the history!\""
]
},
{
"window_name": "mixed",
"suppress_history": false,
"panes": [
{
"shell_command": [
"echo \"command in the history!\""
],
"suppress_history": false
},
{
"shell_command": [
"echo \"command not in the history!\""
],
"suppress_history": true
},
{
"shell_command": [
"echo \"window in the history!\""
]
}
]
}
]
}
Window 0, appended: 1 pane, even-vertical❯ echo "window in the history!"
no layout set
Window 1, suppressed: 1 pane, even-vertical❯ echo "window not in the history!"
no layout set
Window 2, default: 1 pane, even-vertical❯ echo "session in the history!"
no layout set
Window 3, mixed: 3 panes, even-vertical❯ echo "command in the history!"❯ echo "command not in the history!"❯ echo "window in the history!"
no layout set

Workspace file: tests/Fixtures/tmuxp/suppress-history.yaml. Tested by Every_tmuxp_example_loads_through_the_commands_own_loader (tests/LibTmux.Workspace.Cli.Tests/ContractTests.cs; loaded 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 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"
{
"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\""
]
}
]
}
Window 0, zero: 1 pane, even-vertical❯ echo "this window's index will be zero"
no layout set
Window 1, one: 1 pane, even-vertical❯ echo "this window's index will be one"
no layout set
Window 5, five: 1 pane, even-vertical❯ echo "this window's index will be five"
no layout set

Workspace file: tests/Fixtures/tmuxp/window-index.yaml. Tested by Every_tmuxp_example_parses (tests/LibTmux.IntegrationTests/Workspace/WorkspaceFileTests.cs; parsed by the library in a test; the command is not run).

Install LibTmux.Workspace.Cli

The workspace package is separate from the core library.

$ dotnet tool install --global LibTmux.Workspace.Cli

Add $HOME/.dotnet/tools to PATH if the shell cannot find tmux-workspace.

$ dnx LibTmux.Workspace.Cli --yes -- --help

Runs it once from NuGet without installing anything; needs the .NET 10 SDK.

$ dotnet tool install LibTmux.Workspace.Cli

Run at a repository root: it writes dotnet-tools.json, which pins the version for everyone who clones it. Run it as dotnet tmux-workspace.

Build the workspace from a program
src/LibTmux.Workspace.Cli/README.md
session_name: myproject
start_directory: ~/code/myproject
windows:
- window_name: editor
layout: main-vertical
panes:
- vim
- git status
- window_name: server
panes:
- npm run dev

Excerpt of src/LibTmux.Workspace.Cli/README.md, which LibTmux.Workspace.Cli.Tests.dll runs in the repository's CI (.github/workflows/dotnet-tmux.yml).

Packages and integrations

API references

All C# versions and install instructions

Esc

Type to search.

Reference previewOpen reference