libtmux for F#
F#-based tmux client
tmux client library for F#. Control tmux, navigate sessions, windows, and panes, send keys, watch for changes via control mode, capture pane contents
Built on the C# library for .NET. The packages share their source repository and releases.
open Systemopen System.Threadingopen LibTmuxopen LibTmux.FSharp
let runAsync () = task { use deadline = new CancellationTokenSource(TimeSpan.FromSeconds 30.) let token = deadline.Token
let options = ServerConnectionOptions( SocketName = "fsharp-" + Guid.NewGuid().ToString("N"), ConfigurationFile = "/dev/null", TmuxBinaryPath = (Environment.GetEnvironmentVariable "LIBTMUX_TMUX" |> Option.ofObj |> Option.defaultValue "tmux") )
let! owned = LibTmux.Server.CreateOwnedAsync(options, token)
let! session = owned.Value.CreateSessionAsync( NewSessionRequest(Name = "demo", Command = "/bin/sh"), token )
// The new session's active window is its first; name it. let! active = session |> Session.windows |> Query.where (WindowFields.active |> Filter.eq true) |> Query.list token
let! editor = active[0] |> Window.rename token "editor"
// Split its active pane; the new pane is on the right and stays // in the background, so the left pane is still active. let! left = editor |> Window.activePane token
let! right = left |> Pane.split token (SplitPaneRequest(Direction = PaneDirection.Right))
// A second window, also left in the background. let! logs = session |> Session.newWindow token (NewWindowRequest(Name = "logs"))
// Type a command and wait for what it prints, not for its echo. let! waited = right |> Pane.sendAndWait token (TimeSpan.FromSeconds 10.) "printf 'hello from %s\\n' tmux" "hello from tmux"
// Select the right pane, then the logs window. let! selected = right |> Pane.select token let! current = logs |> Window.select token
// Walk a snapshot down from the server: sessions, windows, panes. let! server = LibTmux.Server.ConnectAsync(options, token) let! snapshot = server |> Server.capture token SnapshotDepth.Panes let sessions = snapshot.Sessions
for session in sessions do printfn "session %s" session.Name let windows = session.Windows
for window in windows do let panes = window.Panes let ids = [ for pane in panes -> string pane.Id ]
printfn " window %d:%s: %s" window.Index window.Name (String.Join(" ", ids))
// Then up from one pane to its window and session. let pane = snapshot.Panes |> Seq.find (fun pane -> pane.Id = right.Id) let window = pane.Window let owner = window.Session
printfn "%O is in window %s of session %s" pane.Id window.Name owner.Name }
runAsync().GetAwaiter().GetResult()open Systemopen System.Threadingopen LibTmuxopen LibTmux.FSharp
let runAsync () = task { use deadline = new CancellationTokenSource(TimeSpan.FromSeconds 30.) let token = deadline.Token
let options = ServerConnectionOptions( SocketName = "fsharp-" + Guid.NewGuid().ToString("N"), ConfigurationFile = "/dev/null", TmuxBinaryPath = (Environment.GetEnvironmentVariable "LIBTMUX_TMUX" |> Option.ofObj |> Option.defaultValue "tmux") )
let! owned = LibTmux.Server.CreateOwnedAsync(options, token)
let! session = owned.Value.CreateSessionAsync( NewSessionRequest(Name = "demo", Command = "/bin/sh"), token )
// The new session's active window is its first; name it. let! active = session |> Session.windows |> Query.where (WindowFields.active |> Filter.eq true) |> Query.list token
let! editor = active[0] |> Window.rename token "editor"
// Split its active pane; the new pane is on the right and stays // in the background, so the left pane is still active. let! left = editor |> Window.activePane token
let! right = left |> Pane.split token (SplitPaneRequest(Direction = PaneDirection.Right))
// A second window, also left in the background. let! logs = session |> Session.newWindow token (NewWindowRequest(Name = "logs"))
// Type a command and wait for what it prints, not for its echo. let! waited = right |> Pane.sendAndWait token (TimeSpan.FromSeconds 10.) "printf 'hello from %s\\n' tmux" "hello from tmux"
// Select the right pane, then the logs window. let! selected = right |> Pane.select token let! current = logs |> Window.select token
// Walk a snapshot down from the server: sessions, windows, panes. let! server = LibTmux.Server.ConnectAsync(options, token) let! snapshot = server |> Server.capture token SnapshotDepth.Panes let sessions = snapshot.Sessions
for session in sessions do printfn "session %s" session.Name let windows = session.Windows
for window in windows do let panes = window.Panes let ids = [ for pane in panes -> string pane.Id ]
printfn " window %d:%s: %s" window.Index window.Name (String.Join(" ", ids))
// Then up from one pane to its window and session. let pane = snapshot.Panes |> Seq.find (fun pane -> pane.Id = right.Id) let window = pane.Window let owner = window.Session
printfn "%O is in window %s of session %s" pane.Id window.Name owner.Name }
try runAsync().GetAwaiter().GetResult()with error -> raise (InvalidOperationException( "tmux quickstart failed", error))open Systemopen System.Threadingopen LibTmuxopen LibTmux.FSharp
let runAsync () = task { use deadline = new CancellationTokenSource(TimeSpan.FromSeconds 30.) let token = deadline.Token
let options = ServerConnectionOptions( SocketName = "fsharp-" + Guid.NewGuid().ToString("N"), ConfigurationFile = "/dev/null", TmuxBinaryPath = (Environment.GetEnvironmentVariable "LIBTMUX_TMUX" |> Option.ofObj |> Option.defaultValue "tmux") )
use! owned = LibTmux.Server.CreateOwnedAsync(options, token)
let! session = owned.Value.CreateSessionAsync( NewSessionRequest(Name = "demo", Command = "/bin/sh"), token )
// The new session's active window is its first; name it. let! active = session |> Session.windows |> Query.where (WindowFields.active |> Filter.eq true) |> Query.list token
let! editor = active[0] |> Window.rename token "editor"
// Split its active pane; the new pane is on the right and stays // in the background, so the left pane is still active. let! left = editor |> Window.activePane token
let! right = left |> Pane.split token (SplitPaneRequest(Direction = PaneDirection.Right))
// A second window, also left in the background. let! logs = session |> Session.newWindow token (NewWindowRequest(Name = "logs"))
// Type a command and wait for what it prints, not for its echo. let! waited = right |> Pane.sendAndWait token (TimeSpan.FromSeconds 10.) "printf 'hello from %s\\n' tmux" "hello from tmux"
// Select the right pane, then the logs window. let! selected = right |> Pane.select token let! current = logs |> Window.select token
// Walk a snapshot down from the server: sessions, windows, panes. let! server = LibTmux.Server.ConnectAsync(options, token) let! snapshot = server |> Server.capture token SnapshotDepth.Panes let sessions = snapshot.Sessions
for session in sessions do printfn "session %s" session.Name let windows = session.Windows
for window in windows do let panes = window.Panes let ids = [ for pane in panes -> string pane.Id ]
printfn " window %d:%s: %s" window.Index window.Name (String.Join(" ", ids))
// Then up from one pane to its window and session. let pane = snapshot.Panes |> Seq.find (fun pane -> pane.Id = right.Id) let window = pane.Window let owner = window.Session
printfn "%O is in window %s of session %s" pane.Id window.Name owner.Name }
runAsync().GetAwaiter().GetResult()open Systemopen System.Threadingopen LibTmuxopen LibTmux.FSharp
let runAsync () = task { use deadline = new CancellationTokenSource(TimeSpan.FromSeconds 30.) let token = deadline.Token
let options = ServerConnectionOptions( SocketName = "fsharp-" + Guid.NewGuid().ToString("N"), ConfigurationFile = "/dev/null", TmuxBinaryPath = (Environment.GetEnvironmentVariable "LIBTMUX_TMUX" |> Option.ofObj |> Option.defaultValue "tmux") )
use! owned = LibTmux.Server.CreateOwnedAsync(options, token)
let! session = owned.Value.CreateSessionAsync( NewSessionRequest(Name = "demo", Command = "/bin/sh"), token )
// The new session's active window is its first; name it. let! active = session |> Session.windows |> Query.where (WindowFields.active |> Filter.eq true) |> Query.list token
let! editor = active[0] |> Window.rename token "editor"
// Split its active pane; the new pane is on the right and stays // in the background, so the left pane is still active. let! left = editor |> Window.activePane token
let! right = left |> Pane.split token (SplitPaneRequest(Direction = PaneDirection.Right))
// A second window, also left in the background. let! logs = session |> Session.newWindow token (NewWindowRequest(Name = "logs"))
// Type a command and wait for what it prints, not for its echo. let! waited = right |> Pane.sendAndWait token (TimeSpan.FromSeconds 10.) "printf 'hello from %s\\n' tmux" "hello from tmux"
// Select the right pane, then the logs window. let! selected = right |> Pane.select token let! current = logs |> Window.select token
// Walk a snapshot down from the server: sessions, windows, panes. let! server = LibTmux.Server.ConnectAsync(options, token) let! snapshot = server |> Server.capture token SnapshotDepth.Panes let sessions = snapshot.Sessions
for session in sessions do printfn "session %s" session.Name let windows = session.Windows
for window in windows do let panes = window.Panes let ids = [ for pane in panes -> string pane.Id ]
printfn " window %d:%s: %s" window.Index window.Name (String.Join(" ", ids))
// Then up from one pane to its window and session. let pane = snapshot.Panes |> Seq.find (fun pane -> pane.Id = right.Id) let window = pane.Window let owner = window.Session
printfn "%O is in window %s of session %s" pane.Id window.Name owner.Name }
try runAsync().GetAwaiter().GetResult()with error -> raise (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 Query.list: unchanged.
tmux after Window.rename: renamed window 0:sh to 0:editor.
tmux after Window.activePane: unchanged.
tmux after Pane.split: added pane %1 to window 0:editor.
tmux after Session.newWindow: added window 1:logs.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Pane.sendAndWait: sent keys to pane %1; read pane %1.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Pane.select: selected pane %1 in window 0:editor.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Window.select: selected window 1:logs.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Server.ConnectAsync: unchanged, the call sent no command.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Server.capture: 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 Seq.find: 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.CreateOwnedAsyncreturnedTask<OwnedServerScope>{"configFile": "/dev/null","socketName": "fsharp-0123456789abcdef0123456789abcdef"}3 tmux commands, 1 that changes tmux
-
list-sessionserror connecting to /tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdef (No such file or directory) -
start-serverno output -
list-sessionsno server running on /tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdef
Before these, the library asked tmux about itself 4 times (its version, its daemon, how a control client reads escapes).
-
-
Server.CreateSessionAsyncreturnedTask<Session>{"id": "$0","name": "demo"}3 tmux commands, 2 that change tmux
-
new-session -P -F '#{pid}:#{start_time} #{session_id} #{window_id} #{pane_id} #{window_index}' -d -s demo -- /bin/sh3226196:1793889101 $0 @0 %0 0 -
attach-session -f ignore-size,no-output,new-layoutsno output -
display-message -p -t $0 #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{last_window_ind…/dev/nullLT9b8ad2125ee24bdfb748c8LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee…
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
%session-changed $0 demo
-
-
Query.listreturnedTask<IReadOnlyList<Window>>{"ids": ["@0"]}1 tmux command
-
list-windows -t $0 -f #{==:#{window_active},1} -F #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24b…/dev/nullLT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125e…
-
-
Window.renamereturnedTask<Window>{"id": "@0","index": 0,"name": "editor"}2 tmux commands, 1 that changes tmux
-
rename-window -t @0 -- editorno output -
display-message -p -t $0:0 #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{last_window_i…/dev/nullLT9b8ad2125ee24bdfb748c8LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee…
1 notification from tmux while the call ran
%window-renamed @0 editor
-
-
Window.activePanereturnedTask<Pane>{"id": "%0"}1 tmux command
-
list-panes -t $0:0 -f #{pane_active} -F #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{…/dev/nullLT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125e…
-
-
Pane.splitreturnedTask<Pane>{"id": "%1"}2 tmux commands, 1 that changes tmux
-
split-window -P -F #{pane_id} -t %0 -h -d%1 -
display-message -p -t %1 #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{last_window_ind…/dev/nullLT9b8ad2125ee24bdfb748c8LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee…
1 notification from tmux while the call ran
%layout-change @0 {"V":2,"L":{"t":"h","w":80,"h":24,"x":0,"y":0,"c":[{"t":"p","w":40,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"},{"t":"p","w":39,"h":24,"x":41,"y":0,"i":1,"I":"%1"}]}} {"V":2,"L":{"t":"h","w":80,"h":24,"x":0,"y":0,"c":[{"t":"p","w":40,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"},{"t":"p","w":39,"h":24,"x":41,"y":0,"i":1,"I":"%1"}]}} *
-
-
Session.newWindowreturnedTask<Window>{"id": "@1","index": 1,"name": "logs"}2 tmux commands, 1 that changes tmux
-
new-window -P -F #{window_id} -d -t $0: -n logs@1 -
list-windows -t $0 -F #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{last_window_index}…/dev/nullLT9b8ad2125ee24bdfb748c82LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125e…
1 notification from tmux while the call ran
%window-add @1
-
-
Pane.sendAndWaitreturnedTask<PaneWaitResult>{"found": true}19 tmux commands, 6 that change tmux
-
attach-session -t $0no output -
refresh-client -f new-layoutsno output -
refresh-client -f ignore-sizeno output -
refresh-client -B libtmux-pane-dead:%*:#{pane_dead}no output -
list-panes -t $0:.%1 -F #{pane_id} -f #{==:#{pane_id},%1}%1 -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3226401 0 2000 24 0 0 0 39 -
capture-pane -t %1 -p$ -
capture-pane -t %1 -p -J$ -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3226401 0 2000 24 0 0 0 39 -
send-keys -t %1 -l -- 'printf '\''hello from %s\n'\'' tmux'no output -
send-keys -t %1 Enterno output -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3226401 0 2000 24 2 0 0 39 -
capture-pane -t %1 -p -S 0$ printf 'hello from %s\n' tmux hello from tmux $ -
capture-pane -t %1 -p -S 0 -J$ printf 'hello from %s\n' tmux hello from tmux $ -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3226401 0 2000 24 2 0 0 39 -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3226401 0 2000 24 2 0 0 39 -
capture-pane -t %1 -p$ printf 'hello from %s\n' tmux hello from tmux $ -
capture-pane -t %1 -p -J$ printf 'hello from %s\n' tmux hello from tmux $ -
display-message -t %1 -p -- '#{pane_pid} #{history_size} #{history_limit} #{pane_height} #{cursor_y} #{pane_dead} #{alternate_on} #{pane_width}'3226401 0 2000 24 2 0 0 39
Before these, the library asked tmux about itself 1 time (its version, its daemon, how a control client reads escapes).
6 notifications from tmux while the call ran
%client-session-changed client-3226620 $0 demo%session-changed $0 demo%output %1 printf 'hello from %s\134n' tmux%output %1 \015\012hello from tmux\015\012$%exit%client-detached client-3226620
-
-
Pane.selectreturnedTask<Pane>{"id": "%1"}2 tmux commands, 1 that changes tmux
-
select-pane -t %1no output -
display-message -p -t $0:.%1 #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{last_window…/dev/nullLT9b8ad2125ee24bdfb748c8LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81793889104LT9b8ad2125ee…
1 notification from tmux while the call ran
%window-pane-changed @0 %1
-
-
Window.selectreturnedTask<Window>{"id": "@1","index": 1,"name": "logs"}2 tmux commands, 1 that changes tmux
-
select-window -t @1no output -
display-message -p -t $0:1 #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{last_window_i…/dev/nullLT9b8ad2125ee24bdfb748c8LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81793889104LT9b8ad2125ee…
1 notification from tmux while the call ran
%session-window-changed $0 @1
-
-
Server.ConnectAsyncreturnedTask<Server>{"socketName": "fsharp-0123456789abcdef0123456789abcdef"}The call sent no tmux command.
-
Server.capturereturnedTask<Server>{"panes": 3,"sessions": 1,"windows": 2}3 tmux commands
-
list-sessions -F #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{last_window_index}LT9b8…/dev/nullLT9b8ad2125ee24bdfb748c80LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81793889104LT9b8ad2125e… -
list-windows -a -F #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{last_window_index}LT9…/dev/nullLT9b8ad2125ee24bdfb748c82LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81793889104LT9b8ad2125e… -
list-panes -a -F #{config_files}LT9b8ad2125ee24bdfb748c8#{line}LT9b8ad2125ee24bdfb748c8#{next_session_id}LT9b8ad2125ee24bdfb748c8#{pid}LT9b8ad2125ee24bdfb748c8#{socket_path}LT9b8ad2125ee24bdfb748c8#{start_time}LT9b8ad2125ee24bdfb748c8#{uid}LT9b8ad2125ee24bdfb748c8#{user}LT9b8ad2125ee24bdfb748c8#{version}LT9b8ad2125ee24bdfb748c8#{active_window_index}LT9b8ad2125ee24bdfb748c8#{last_window_index}LT9b8…/dev/nullLT9b8ad2125ee24bdfb748c82LT9b8ad2125ee24bdfb748c8$1LT9b8ad2125ee24bdfb748c83226196LT9b8ad2125ee24bdfb748c8/tmp/tmux-1000/fsharp-0123456789abcdef0123456789abcdefLT9b8ad2125ee24bdfb748c81793889101LT9b8ad2125ee24bdfb748c81000LT9b8ad2125ee24bdfb748c8dLT9b8ad2125ee24bdfb748c83.8aLT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81LT9b8ad2125ee24bdfb748c81793889104LT9b8ad2125e…
-
-
Server.SessionsreturnedCapturedRelation<Session>{"ids": ["$0"]}The call sent no tmux command.
-
Session.WindowsreturnedCapturedRelation<Window>{"ids": ["@0","@1"]}The call sent no tmux command.
-
Window.PanesreturnedCapturedRelation<Pane>{"ids": ["%0","%1"]}The call sent no tmux command.
-
Window.PanesreturnedCapturedRelation<Pane>{"ids": ["%2"]}The call sent no tmux command.
-
Seq.findreturnedPane{"id": "%1"}The call sent no tmux command.
-
Pane.WindowreturnedWindow{"id": "@0","index": 0,"name": "editor"}The call sent no tmux command.
-
Window.SessionreturnedSession{"id": "$0","name": "demo"}The call sent no tmux command.
-
OwnedServerScope.DisposeAsyncreturnedValueTasknull2 tmux commands, 1 that changes tmux
-
display-message -p #{pid}3226196 -
kill-serverno 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
%exit
-
Run this example
.NET SDK 10.0.303, .NET 8 and 10 runtimes, tmux 3.4 or newer on Linux/macOS
Save the program above as app/Program.fs 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.fsproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFrameworks>net8.0;net10.0</TargetFrameworks> <LangVersion>10.0</LangVersion> <TreatWarningsAsErrors>true</TreatWarningsAsErrors> <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference> <DisableImplicitLibraryPacksFolder>true</DisableImplicitLibraryPacksFolder> </PropertyGroup> <ItemGroup> <Compile Include="Program.fs" /> <PackageReference Include="FSharp.Core" Version="[10.1.303]" /> <PackageReference Include="LibTmux.FSharp" 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 appdotnet restore Example.fsprojdotnet build Example.fsproj -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.dllExpected output
session demo window 0:editor: %0 %1 window 1:logs: %2%1 is in window editor of session demoInstall LibTmux.FSharp
$ dotnet package add LibTmux.FSharp --version 0.1.1PM> NuGet\Install-Package LibTmux.FSharp -Version 0.1.1<PackageReference Include="LibTmux.FSharp" Version="0.1.1" /><Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="LibTmux.FSharp" Version="0.1.1" />
</ItemGroup>
</Project><PackageReference Include="LibTmux.FSharp" />$ paket add LibTmux.FSharp --version 0.1.1 --interactive#r "nuget: LibTmux.FSharp, 0.1.1"#:package LibTmux.FSharp@0.1.1#addin nuget:?package=LibTmux.FSharp&version=0.1.1&loaddependencies=true$ dotnet add reference ../libtmux-dotnet/src/LibTmux.FSharp/LibTmux.FSharp.fsproj.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.
Guides
Task guides for F#.
Examples
Complete programs, sourced from the code each port tests.
Concepts
The domain model every port shares.