AgentCreate the session.
Result
{ "changed": "Created session $0.", "paneId": "%0", "windowId": "@0", "sessionId": "$0"}Choose documentation 3
No matching documentation.
No matching versions.
Current version
latestNo matching languages.
Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.
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
Control tmux from C# code 0.x Released; the API may change. Read more Core Library home →
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);}tmux before the first call: no server is running.
tmux after Server.CreateOwnedAsync: no server is running.
tmux after Server.CreateSessionAsync: added session demo.
tmux after Session.GetWindowsAsync: unchanged.
tmux after Window.RenameAsync: renamed window 0:sh to 0:editor.
tmux after Window.GetActivePaneAsync: unchanged.
tmux after Pane.SplitAsync: added pane %1 to window 0:editor.
tmux after Session.CreateWindowAsync: added window 1:logs.
tmux after Pane.SendTextAsync: sent keys to pane %1.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Pane.CaptureAsync: 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 Server.CaptureSnapshotAsync: unchanged.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Server.Sessions: unchanged, the call sent no command.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Session.Windows: unchanged, the call sent no command.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Window.Panes: unchanged, the call sent no command.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Window.Panes: unchanged, the call sent no command.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Server.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 Window.Session: unchanged, the call sent no command.
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"}list-sessions error connecting to /tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdef (No such file or directory) start-server no output 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"}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 attach-session -f ignore-size,no-output,new-layouts no output 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).
%session-changed $0 demo Session.GetWindowsAsync returned Task<IReadOnlyList<Window>>
{ "id": "@0", "index": 0, "name": "sh"}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"}rename-window -t @0 -- editor no output 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… %window-renamed @0 editor Window.GetActivePaneAsync returned Task<Pane>
{ "id": "%0"}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"}split-window -P -F #{pane_id} -t %0 -h -d -- /bin/sh %1 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… %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"}new-window -P -F #{window_id} -d -t $0: -n logs -- /bin/sh @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/nullLT8f4639af840b4599b2362e2LT8f4639af840b4599b2362e$1LT8f4639af840b4599b2362e3162114LT8f4639af840b4599b2362e/tmp/tmux-1000/quickstart-0123456789abcdef0123456789abcdefLT8f4639af840b4599b2362e1793888574LT8f4639af840b4599b2362e1000LT8f4639af840b4599b2362edLT8f4639af840b4599b2362e3.8aLT8f4639af840b4599b2362e0LT8f4639af840b4599b2362e1LT8f4639af840b4599b2362e1793888575LT8f4639… %window-add @1 Pane.SendTextAsync returned Task
nullsend-keys -t %1 -l -- 'printf '\''hello from %s\n'\'' tmux' no output send-keys -t %1 Enter no output Pane.CaptureAsync returned Task<IReadOnlyList<string>>
[ "$ printf 'hello from %s\\n' tmux", "hello from tmux", "$"]capture-pane -t %1 -p $ printf 'hello from %s\n' tmux
hello from tmux
$ Pane.SelectAsync returned Task<Pane>
{ "id": "%1"}select-pane -t %1 no output 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… %window-pane-changed @0 %1 Window.SelectAsync returned Task<Window>
{ "id": "@1", "index": 1, "name": "logs"}select-window -t @1 no output 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… %session-window-changed $0 @1 Server.CaptureSnapshotAsync returned Task<Server>
{ "sessions": 1, "windows": 2, "panes": 3}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… 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… 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
nulldisplay-message -p #{pid} 3162114 kill-server no output Before these, the library asked tmux about itself 1 time (its version, its daemon, how a control client reads escapes).
%exit.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.
<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>{ "sdk": { "version": "10.0.303", "rollForward": "disable", "allowPrerelease": false }, "test": { "runner": "Microsoft.Testing.Platform" }}# Save the files above at their displayed relative paths.cd appdotnet restore Example.csprojdotnet build Example.csproj -c Release --no-restore --warnaserrorexport TMUX_TMPDIR=/tmp/libtmux-dotnet-devmkdir -p "$TMUX_TMPDIR"unset TMUX TMUX_PANEdotnet bin/Release/net8.0/Example.dlldotnet bin/Release/net10.0/Example.dllsession demo window 0:editor: %0 %1 window 1:logs: %2%1 is in window editor of session demoLibTmux$ dotnet package add LibTmuxPM> NuGet\Install-Package LibTmux -Version 0.1.1<PackageReference Include="LibTmux" Version="0.1.1" /><Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="LibTmux" Version="0.1.1" />
</ItemGroup>
</Project><PackageReference Include="LibTmux" />$ paket add LibTmux --version 0.1.1 --interactive#r "nuget: LibTmux, 0.1.1"#:package LibTmux@0.1.1#addin nuget:?package=LibTmux&version=0.1.1&loaddependencies=true$ dotnet add reference ../libtmux-dotnet/src/LibTmux/LibTmux.csproj.NET 10 SDK: run in your project directory. On .NET 8 or 9, use dotnet add package with the same arguments.
Run in Visual Studio on Windows, in Tools > NuGet Package Manager > Package Manager Console. Choose the target project in that console.
Add this inside an ItemGroup in your .csproj or .fsproj, then run dotnet restore. For central version management, use the CPM tab.
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.
Requires Paket and a solution initialized with paket init. The interactive prompt selects the projects that should reference the package.
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.
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.
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.
Pins the tagged source; the registry release is the default.
Give an assistant tmux tools concept Working example; may change without notice. Read more MCP home →
tmux before the first call.
tmux after create_session.
tmux after split_window.
tmux after list_windows: unchanged, the call only reads.
$ pytest -q .. [100%] 2 passed in 0.01s
tmux after run_shell_command.
$ pytest -q .. [100%] 2 passed in 0.01s
$ cat checks.log 2026-01-01 checks started 2026-01-01 checks finished
tmux after run_shell_command.
tmux after kill_session.
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.
{ "changed": "Created session $0.", "paneId": "%0", "windowId": "@0", "sessionId": "$0"}AgentSplit the pane the create result returned (%0) in two.
{ "changed": "Split %0; the new pane is %1.", "paneId": "%1", "windowId": "@0", "sessionId": "$0"}AgentRead the window's layout.
{ "result": [ { "windowId": "@0", "sessionId": "$0", "index": 0, "name": "sh", "width": 80, "height": 24, "active": true, "paneCount": 2, "layout": "8205,80x24,0,0{40x24,0,0,0,39x24,41,0,1}" } ]}AgentRun the tests in the pane the create result returned (%0).
{ "paneId": "%0", "exitStatus": 0, "timedOut": false, "output": { "lines": [ ".. [100%]", "2 passed in 0.01s" ], "truncated": false, "droppedLines": 0, "droppedBytes": 0 }, "elapsedSeconds": 0.48, "effectiveTimeoutSeconds": 30, "linesMissed": false, "anchorLost": false, "started": true, "paneExited": false}AgentShow the log in the new pane the split returned (%1).
{ "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.025, "effectiveTimeoutSeconds": 30, "linesMissed": false, "anchorLost": false, "started": true, "paneExited": false}AgentRemove the session once the result is read.
{ "changed": "Killed session $0.", "paneId": null, "windowId": null, "sessionId": "$0"}pytest printed 2 passed and checks.log ends with checks finished. I removed the checks session.
LibTmux.McpChoose your client and configuration scope, then run the command or paste the configuration.
$ claude mcp add tmux -- dnx LibTmux.Mcp --yes$ claude mcp add tmux --scope user -- dnx LibTmux.Mcp --yes$ claude mcp add tmux --scope project -- dnx LibTmux.Mcp --yes$ dotnet tool install --global LibTmux.Mcp$ claude mcp add tmux -- libtmux-mcp$ dotnet tool install --global LibTmux.Mcp$ claude mcp add tmux --scope user -- libtmux-mcp$ dotnet tool install --global LibTmux.Mcp$ claude mcp add tmux --scope project -- libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "dnx",
"args": ["LibTmux.Mcp", "--yes"]
}
}
}$ dotnet tool install --global LibTmux.Mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ codex mcp add tmux -- dnx LibTmux.Mcp --yes[mcp_servers.tmux]
command = "dnx"
args = ["LibTmux.Mcp", "--yes"]$ dotnet tool install --global LibTmux.Mcp$ codex mcp add tmux -- libtmux-mcp$ dotnet tool install --global LibTmux.Mcp[mcp_servers.tmux]
command = "libtmux-mcp"$ gemini mcp add --scope user tmux dnx -- LibTmux.Mcp --yes$ gemini mcp add --scope project tmux dnx -- LibTmux.Mcp --yes$ dotnet tool install --global LibTmux.Mcp$ gemini mcp add --scope user tmux libtmux-mcp$ dotnet tool install --global LibTmux.Mcp$ gemini mcp add --scope project tmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "dnx",
"args": ["LibTmux.Mcp", "--yes"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "dnx",
"args": ["LibTmux.Mcp", "--yes"]
}
}
}$ dotnet tool install --global LibTmux.Mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ dotnet tool install --global LibTmux.Mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ grok mcp add --scope user tmux -- dnx LibTmux.Mcp --yes$ grok mcp add --scope project tmux -- dnx LibTmux.Mcp --yes$ dotnet tool install --global LibTmux.Mcp$ grok mcp add --scope user tmux -- libtmux-mcp$ dotnet tool install --global LibTmux.Mcp$ grok mcp add --scope project tmux -- libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "dnx",
"args": ["LibTmux.Mcp", "--yes"]
}
}
}$ dotnet tool install --global LibTmux.Mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ opencode mcp add tmux -- dnx LibTmux.Mcp --yes$ dotnet tool install --global LibTmux.Mcp$ opencode mcp add tmux -- libtmux-mcpWrites ~/.claude.json (this project).
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Writes ~/.claude.json (all projects).
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Writes .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.
Writes ~/.claude.json (this project).
Installs the libtmux-mcp tool from NuGet.
Writes ~/.claude.json (all projects).
Installs the libtmux-mcp tool from NuGet.
Writes .mcp.json (in repo, version-controlled).
Installs the libtmux-mcp tool from NuGet.
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Installs the libtmux-mcp tool from NuGet.
Writes ~/.codex/config.toml.
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
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.
Writes ~/.codex/config.toml.
Installs the libtmux-mcp tool from NuGet.
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.
Writes ~/.gemini/settings.json.
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Writes .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.
Writes ~/.gemini/settings.json.
Installs the libtmux-mcp tool from NuGet.
Writes .gemini/settings.json (in repo).
Installs the libtmux-mcp tool from NuGet.
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Installs the libtmux-mcp tool from NuGet.
Installs the libtmux-mcp tool from NuGet.
Writes ~/.grok/config.toml.
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Writes ./.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.
Writes ~/.grok/config.toml.
Installs the libtmux-mcp tool from NuGet.
Writes ./.grok/config.toml (in repo).
Installs the libtmux-mcp tool from NuGet.
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Installs the libtmux-mcp tool from NuGet.
Writes ~/.config/opencode/opencode.jsonc.
Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.
Writes ~/.config/opencode/opencode.jsonc.
Installs the libtmux-mcp tool from NuGet.
Load a workspace file concept Working example; may change without notice. Read more Workspace Manager home →
A window of two panes.
session_name: myprojectstart_directory: ~/code/myprojectwindows: - 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" ] } ]}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).
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/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).
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/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).
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/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).
The main-horizontal layout gives the first pane the top of the window and splits the rest below it.
session_name: main-pane-heightstart_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" } ]}
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 sets variables for a session, a window or a pane.
session_name: Environment variables testenvironment: 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}" } ] } ]}
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 chooses where a session, a window or a pane starts.
session_name: start directorystart_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.'" ] } ] } ]}
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).
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/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).
An empty entry, null, pane or blank opens a pane with no command.
session_name: Blank pane testwindows: # 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" } ] } ]}
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).
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" ] } ] } ]}
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: true selects a window or a pane when the session is built.
session_name: focuswindows: - 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" ] } ]}
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 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/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).
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/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).
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/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).
A pane can start its own shell or program, and window_shell sets the default for a window.
session_name: Pane shell examplewindows: - 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" } ] } ]}
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).
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/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).
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/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).
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\"" } ] } ] } ]}
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).
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\"" } ] } ] } ]}
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).
A setup command with sleep_before and sleep_after gives a virtualenv time to activate before the commands run.
session_name: virtualenvshell_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: 1windows: - 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" ] } ] } ]}
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).
suppress_history chooses whether commands reach the shell history, per session, window, pane or command.
session_name: suppresssuppress_history: falsewindows: - 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!\"" ] } ] } ]}
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 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/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).
LibTmux.Workspace.CliThe workspace package is separate from the core library.
$ dotnet tool install --global LibTmux.Workspace.Cli$ tmux-workspace load ./workspace.yaml$ dnx LibTmux.Workspace.Cli --yes -- --help$ dotnet tool install LibTmux.Workspace.Cli$ tmux-workspace load ./workspace.yamlAdd $HOME/.dotnet/tools to PATH if the shell cannot find tmux-workspace.
Runs it once from NuGet without installing anything; needs the .NET 10 SDK.
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.
session_name: myprojectstart_directory: ~/code/myprojectwindows: - 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.
This program is tested on every change.
Subject-by-subject, with C# in every code block.
Task guides for C#.
Complete programs, sourced from the code each port tests.
The domain model every port shares.
Reference preview