JuliaHome

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 Julia

Julia-based tmux client

tmux client library for Julia. 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 LibTmux
# 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.
owned = open_server()
server = owned.server
demo = new_session(server; name="demo")
# Lay out the session: name its window, split it, add a second window.
editor = only(windows(snapshot(server, demo))).ref
rename_window(server, editor, "editor")
left = only(filter(p -> p.active, panes(snapshot(server, editor)))).ref
right = split_window(server, left; direction=:right)
logs = new_window(server, demo; name="logs")
# Type a command into the new pane and wait for what it prints.
send_keys(server, right, "printf 'hello from %s\\n' tmux", "Enter")
wait_for_text(server, right, "hello from tmux"; baseline=true)
# Move the focus an attached client sees: the pane, then the window.
select_pane(server, right)
select_window(server, WindowLinkRef(demo, logs, 1))
# Walk the objects: down from the server, then up from one pane.
snap = snapshot(server)
listed = sessions(snap)
for each in listed
println("session ", each.name)
links = windowlinks(each)
wins = [window(link) for link in links]
for (link, win) in zip(links, wins)
members = panes(win)
ids = join((string(p.id) for p in members), " ")
println(" window ", link.index, ":", win.name, ": ", ids)
end
end
pane = snap[right]
home = window(pane)
owner = session(only(windowlinks(home)))
println(string(pane.id), " is in window ", home.name,
" of session ", owner.name)
using LibTmux
try
# A private server: a socket and an empty config of its own, so this
# neither touches nor is changed by a tmux you already use.
owned = open_server()
server = owned.server
demo = new_session(server; name="demo")
# Lay out the session: name its window, split it, add a second window.
editor = only(windows(snapshot(server, demo))).ref
rename_window(server, editor, "editor")
left = only(filter(p -> p.active, panes(snapshot(server, editor)))).ref
right = split_window(server, left; direction=:right)
logs = new_window(server, demo; name="logs")
# Type a command into the new pane and wait for what it prints.
send_keys(server, right, "printf 'hello from %s\\n' tmux", "Enter")
wait_for_text(server, right, "hello from tmux"; baseline=true)
# Move the focus an attached client sees: the pane, then the window.
select_pane(server, right)
select_window(server, WindowLinkRef(demo, logs, 1))
# Walk the objects: down from the server, then up from one pane.
snap = snapshot(server)
listed = sessions(snap)
for each in listed
println("session ", each.name)
links = windowlinks(each)
wins = [window(link) for link in links]
for (link, win) in zip(links, wins)
members = panes(win)
ids = join((string(p.id) for p in members), " ")
println(" window ", link.index, ":", win.name, ": ", ids)
end
end
pane = snap[right]
home = window(pane)
owner = session(only(windowlinks(home)))
println(string(pane.id), " is in window ", home.name,
" of session ", owner.name)
catch error
println(stderr, "tmux quickstart failed: ", sprint(showerror, error))
rethrow()
end
using LibTmux
# 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.
with_server() do server
demo = new_session(server; name="demo")
# Lay out the session: name its window, split it, add a second window.
editor = only(windows(snapshot(server, demo))).ref
rename_window(server, editor, "editor")
left = only(filter(p -> p.active, panes(snapshot(server, editor)))).ref
right = split_window(server, left; direction=:right)
logs = new_window(server, demo; name="logs")
# Type a command into the new pane and wait for what it prints.
send_keys(server, right, "printf 'hello from %s\\n' tmux", "Enter")
wait_for_text(server, right, "hello from tmux"; baseline=true)
# Move the focus an attached client sees: the pane, then the window.
select_pane(server, right)
select_window(server, WindowLinkRef(demo, logs, 1))
# Walk the objects: down from the server, then up from one pane.
snap = snapshot(server)
listed = sessions(snap)
for each in listed
println("session ", each.name)
links = windowlinks(each)
wins = [window(link) for link in links]
for (link, win) in zip(links, wins)
members = panes(win)
ids = join((string(p.id) for p in members), " ")
println(" window ", link.index, ":", win.name, ": ", ids)
end
end
pane = snap[right]
home = window(pane)
owner = session(only(windowlinks(home)))
println(string(pane.id), " is in window ", home.name,
" of session ", owner.name)
end
using LibTmux
try
# A private server: a socket and an empty config of its own, so this
# neither touches nor is changed by a tmux you already use.
with_server() do server
demo = new_session(server; name="demo")
# Lay out the session: name its window, split it, add a second window.
editor = only(windows(snapshot(server, demo))).ref
rename_window(server, editor, "editor")
left = only(filter(p -> p.active, panes(snapshot(server, editor)))).ref
right = split_window(server, left; direction=:right)
logs = new_window(server, demo; name="logs")
# Type a command into the new pane and wait for what it prints.
send_keys(server, right, "printf 'hello from %s\\n' tmux", "Enter")
wait_for_text(server, right, "hello from tmux"; baseline=true)
# Move the focus an attached client sees: the pane, then the window.
select_pane(server, right)
select_window(server, WindowLinkRef(demo, logs, 1))
# Walk the objects: down from the server, then up from one pane.
snap = snapshot(server)
listed = sessions(snap)
for each in listed
println("session ", each.name)
links = windowlinks(each)
wins = [window(link) for link in links]
for (link, win) in zip(links, wins)
members = panes(win)
ids = join((string(p.id) for p in members), " ")
println(" window ", link.index, ":", win.name, ": ", ids)
end
end
pane = snap[right]
home = window(pane)
owner = session(only(windowlinks(home)))
println(string(pane.id), " is in window ", home.name,
" of session ", owner.name)
end
catch error
println(stderr, "tmux quickstart failed: ", sprint(showerror, error))
rethrow()
end
Example details
No tmux server yet

tmux before the first call: no server is running.

No tmux server yet

tmux after with_server: no server is running; the call sent no command.

%0 sh
[demo]

tmux after new_session: added session demo.

%0 sh
[demo]

tmux after snapshot: unchanged.

%0 sh
[demo]

tmux after rename_window: renamed window 0:sh to 0:editor.

%0 sh
[demo]

tmux after snapshot: unchanged.

%0 sh
%1 sh
[demo]

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

%0 sh
%1 sh
[demo]

tmux after new_window: added window 1:logs.

%0 sh
%1 sh
[demo]

tmux after send_keys: sent keys to pane %1.

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

tmux after wait_for_text: read pane %1.

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

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

%2 sh
[demo]

tmux after select_window: selected window 1:logs.

%2 sh
[demo]

tmux after snapshot: unchanged.

%2 sh
[demo]

tmux after sessions: unchanged, the call sent no command.

%2 sh
[demo]

tmux after windowlinks: unchanged, the call sent no command.

%2 sh
[demo]

tmux after window: unchanged, the call sent no command.

%2 sh
[demo]

tmux after panes: unchanged, the call sent no command.

%2 sh
[demo]

tmux after panes: unchanged, the call sent no command.

%2 sh
[demo]

tmux after Snapshot[PaneRef]: unchanged, the call sent no command.

%2 sh
[demo]

tmux after window: unchanged, the call sent no command.

%2 sh
[demo]

tmux after session: unchanged, the call sent no command.

Before the first call

No tmux server is running yet.

with_server returned Server

{
"socketPath": "/tmp/libtmux-julia-AbC123/s",
"tmux": "tmux"
}

The call sent no tmux command.

new_session returned SessionRef

{
"id": "$0"
}
2 tmux commands, 2 that change tmux
  1. run-shell -C libtmux-version-465045ed74ec4dd197fc1cc5f73f0fef#{version} unknown command: libtmux-version-465045ed74ec4dd197fc1cc5f73f0fef3.8a
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-cbb9aebed37b4e658e50ab5a318dbcf7 ; new-session -d -P -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id}' -s demo -- 3441885 1793890630 /tmp/libtmux-julia-AbC123/s \d0

snapshot returned Snapshot

{
"window": "@0"
}
9 tmux commands
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-9d45de1df1384f03a09737c2d38fb790 ; display-message -p '#{s|^.*$|A\\B C D|;s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version}' A\\B\tC\nD
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-f02f9c82a2f94cb29d454113d03ad31f ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s
  3. if-shell -F #{==:#{version},3.8a} '' libtmux-version-4ef6f1f9d0fe438ab48542ed2db0ff2c ; list-sessions -f #{==:#{session_id},$0} -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_attached} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_created} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\… \d0 demo 0 1793890631 1793890631
  4. if-shell -F #{==:#{version},3.8a} '' libtmux-version-285052c50b2945c582c8f526993ab50d ; list-windows -t $0 -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_width} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_height} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s… @0 sh 80 24 \d0 0 1 {"V":2,"L":{"t":"p","w":80,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"}} {"V":2,"L":{"t":"p","w":80,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"}} 0 1793890631
  5. if-shell -F #{==:#{version},3.8a} '' libtmux-version-32fed395ac7f454fbf27d0fa8ef8d4c9 ; list-panes -s -t $0 -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_index} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_active} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_dead} #{s|\\|\\\\|;s|[$]|\\d… %0 @0 0 1 0 80 24 sh /tmp/marked host 3442058 /dev/pts/14 0 2000 2 0
  6. if-shell -F #{==:#{version},3.8a} '' libtmux-version-b8ee171b0f5f47c3b995c427e672232a ; list-sessions -f #{==:#{session_id},$0} -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_attached} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_created} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\… \d0 demo 0 1793890631 1793890631
  7. if-shell -F #{==:#{version},3.8a} '' libtmux-version-0b01827cc4e04752a4330e319138995f ; list-windows -t $0 -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_width} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_height} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s… @0 sh 80 24 \d0 0 1 {"V":2,"L":{"t":"p","w":80,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"}} {"V":2,"L":{"t":"p","w":80,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"}} 0 1793890631
  8. if-shell -F #{==:#{version},3.8a} '' libtmux-version-d300136b9b8e4698b31e42d3b48d8f47 ; list-panes -s -t $0 -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_index} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_active} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_dead} #{s|\\|\\\\|;s|[$]|\\d… %0 @0 0 1 0 80 24 sh /tmp/marked host 3442058 /dev/pts/14 0 2000 2 0
  9. if-shell -F #{==:#{version},3.8a} '' libtmux-version-5f1aa1c0684c4e81b42b09c7c5ac0983 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s

rename_window returned CommandResult

{
"exitcode": 0
}
3 tmux commands, 1 that changes tmux
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-9ccb18b99b7343029ffdd702e708e462 ; display-message -p '#{s|^.*$|A\\B C D|;s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version}' A\\B\tC\nD
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-d1c5e54b9ab549239c91f4412cf0d0a6 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s
  3. if-shell -F #{==:#{version},3.8a} '' libtmux-version-81243a57913144adbcf3a4b49ead44fe ; rename-window -t @0 -- editor no output

snapshot returned Snapshot

{
"pane": "%0"
}
9 tmux commands
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-ef2cb5112cd5497a8543c4503cd55422 ; display-message -p '#{s|^.*$|A\\B C D|;s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version}' A\\B\tC\nD
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-b929b2eddc3949d682c8f048435a06e5 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s
  3. if-shell -F #{==:#{version},3.8a} '' libtmux-version-0ba9b16d373043079d539d143d214a87 ; list-windows -a -f #{==:#{window_id},@0} -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_width} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_height} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:sess… @0 editor 80 24 \d0 0 1 {"V":2,"L":{"t":"p","w":80,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"}} {"V":2,"L":{"t":"p","w":80,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"}} 0 1793890631
  4. if-shell -F #{==:#{version},3.8a} '' libtmux-version-79b0437f39ce45b3a39d37cbf192e3c0 ; list-sessions -f #{m/r:^[$](0)$,#{session_id}} -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_attached} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_created} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|… \d0 demo 0 1793890631 1793890631
  5. if-shell -F #{==:#{version},3.8a} '' libtmux-version-61a6eba6063a4a399eeaa4575d8a8684 ; list-panes -t @0 -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_index} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_active} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_dead} #{s|\\|\\\\|;s|[$]|\\d|;s… %0 @0 0 1 0 80 24 sh /tmp/marked host 3442058 /dev/pts/14 0 2000 2 0
  6. if-shell -F #{==:#{version},3.8a} '' libtmux-version-391b290769654a2cbd0f88ae1d722d55 ; list-windows -a -f #{==:#{window_id},@0} -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_width} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_height} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:sess… @0 editor 80 24 \d0 0 1 {"V":2,"L":{"t":"p","w":80,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"}} {"V":2,"L":{"t":"p","w":80,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%0"}} 0 1793890631
  7. if-shell -F #{==:#{version},3.8a} '' libtmux-version-81c7dbab83fa4225985cf43b705d9959 ; list-sessions -f #{m/r:^[$](0)$,#{session_id}} -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_attached} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_created} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|… \d0 demo 0 1793890631 1793890631
  8. if-shell -F #{==:#{version},3.8a} '' libtmux-version-76dfabd48f4442a5a1894ef4ed3c871e ; list-panes -t @0 -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_index} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_active} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_dead} #{s|\\|\\\\|;s|[$]|\\d|;s… %0 @0 0 1 0 80 24 sh /tmp/marked host 3442058 /dev/pts/14 0 2000 2 0
  9. if-shell -F #{==:#{version},3.8a} '' libtmux-version-e6147f39a505402ab58ccf0162c354b2 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s

split_window returned PaneRef

{
"pane": "%1"
}
3 tmux commands, 1 that changes tmux
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-0d9bfd316c33447c9b0d15b240c6765b ; display-message -p '#{s|^.*$|A\\B C D|;s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version}' A\\B\tC\nD
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-8516fe805ffb4faebfa0bd930afece46 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s
  3. if-shell -F #{==:#{version},3.8a} '' libtmux-version-d71a02c9acb24bfdbc78bee1ab63c1ac ; split-window -d -P -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_id}' -t %0 -h -- 3441885 1793890630 /tmp/libtmux-julia-AbC123/s %1

new_window returned WindowRef

{
"window": "@1"
}
3 tmux commands, 1 that changes tmux
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-10884d55952b4848b5840b1e94ebdca5 ; display-message -p '#{s|^.*$|A\\B C D|;s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version}' A\\B\tC\nD
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-7371001bb5614d35b330b81d59055823 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s
  3. if-shell -F #{==:#{version},3.8a} '' libtmux-version-2452f1d108494e429eb29f6b0b1bbf6d ; new-window -d -P -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id}' -t $0: -n logs -- 3441885 1793890630 /tmp/libtmux-julia-AbC123/s @1

send_keys returned CommandResult

{
"exitcode": 0
}
3 tmux commands, 1 that changes tmux
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-55866a72153346748e35d00434521e22 ; display-message -p '#{s|^.*$|A\\B C D|;s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version}' A\\B\tC\nD
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-8f06ee6323ed4354ae3a26910219ec11 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s
  3. if-shell -F #{==:#{version},3.8a} '' libtmux-version-79d8597862c247eeab577a2975ae215c ; send-keys -t %1 -- 'printf '\''hello from %s\n'\'' tmux' Enter no output

wait_for_text returned ScreenWaitResult

{
"source": "baseline"
}
1 tmux command, 1 that changes tmux
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-cafd9f55e97d41218c19365c3573d15f ; capture-pane -p -J -t %1 ; run-shell -C -t %1 libtmux-screen-d833d97117db4003#{q:pane_id}-#{q:pane_dead}-#{q:alternate_on}-#{q:pid}-#{q:start_time}| $ printf 'hello from %s\n' tmux hello from tmux $

select_pane returned CommandResult

{
"exitcode": 0
}
3 tmux commands, 1 that changes tmux
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-c4806e1305e44df9ade40a59080ea8e1 ; display-message -p '#{s|^.*$|A\\B C D|;s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version}' A\\B\tC\nD
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-59fbea4cdc174c44acd0b6488eae1d5b ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s
  3. if-shell -F #{==:#{version},3.8a} '' libtmux-version-4caff35b1e92492684f74521b437f0bf ; select-pane -t %1 no output

select_window returned CommandResult

{
"exitcode": 0
}
4 tmux commands, 1 that changes tmux
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-05de955e80694346b7abfde866439e70 ; display-message -p '#{s|^.*$|A\\B C D|;s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version}' A\\B\tC\nD
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-83272f07bb98465eb06ece31564abdb5 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s
  3. if-shell -F #{==:#{version},3.8a} '' libtmux-version-6325ad74e74043ddb55f078a2ea60e22 ; list-windows -t $0 -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_index} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id}' 0 @0 1 @1
  4. if-shell -F #{==:#{version},3.8a} '' libtmux-version-23fceeabb69d4ab69c18b486fa45dc7b ; select-window -t $0:1 no output

snapshot returned Snapshot

{
"sessions": 1,
"panes": 3,
"windows": 2
}
11 tmux commands
  1. if-shell -F #{==:#{version},3.8a} '' libtmux-version-0dadc8c62ce34043a1aa2fe094ebaf06 ; display-message -p '#{s|^.*$|A\\B C D|;s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version}' A\\B\tC\nD
  2. if-shell -F #{==:#{version},3.8a} '' libtmux-version-f1f9e9ccb6574b13ad9993b0ad2fb767 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s
  3. if-shell -F #{==:#{version},3.8a} '' libtmux-version-2d597e77a4d946e3a4109aab72e102a1 ; list-sessions -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_attached} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_created} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_activity} #{s|\… \d0 demo 0 1793890631 1793890631
  4. if-shell -F #{==:#{version},3.8a} '' libtmux-version-f7f1308aa46940df9eb9989d59978085 ; list-windows -a -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_width} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_height} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$… @0 editor 80 24 \d0 0 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,"l":0,"i":0,"I":"%0"},{"t":"p","w":39,"h":24,"x":41,"y":0,"a":true,"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,"l":0,"i":0,"I":"%0"},{"t":"p","w":39,"h":24,"x":41,"y":0,"a":true,"i":1,"I":"%1"}]}} 0 1793890636 @1 logs 80 24 \d0 1…
  5. if-shell -F #{==:#{version},3.8a} '' libtmux-version-f4f85bf687204eb99181c354c354f960 ; list-panes -a -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_index} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_active} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_dead} #{s|\\|\\\\|;s|[$]|\\d|;s| |… %0 @0 0 0 0 40 24 sh /tmp/marked host 3442058 /dev/pts/14 0 2000 2 0 %1 @0 1 1 0 39 24 sh /tmp/marked host 3442541 /dev/pts/16 0 2000 2 2 %2 @1 0 1 0 80 24 sh /tmp/marked host 3442666 /dev/pts/17 0 2000 2 0
  6. if-shell -F #{==:#{version},3.8a} '' libtmux-version-fe2889d3c6c548b6a01a3d647626fd35 ; list-clients -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:client_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:client_pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:client_created} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:client_activity}' no output
  7. if-shell -F #{==:#{version},3.8a} '' libtmux-version-4815c9935096410bb1fd5dc11e584a7b ; list-sessions -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_attached} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_created} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_activity} #{s|\… \d0 demo 0 1793890631 1793890631
  8. if-shell -F #{==:#{version},3.8a} '' libtmux-version-e988d0c6698343428e33d7f2b6405c13 ; list-windows -a -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_width} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_height} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$… @0 editor 80 24 \d0 0 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,"l":0,"i":0,"I":"%0"},{"t":"p","w":39,"h":24,"x":41,"y":0,"a":true,"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,"l":0,"i":0,"I":"%0"},{"t":"p","w":39,"h":24,"x":41,"y":0,"a":true,"i":1,"I":"%1"}]}} 0 1793890636 @1 logs 80 24 \d0 1…
  9. if-shell -F #{==:#{version},3.8a} '' libtmux-version-7d60def5f8aa4b21b562502025462822 ; list-panes -a -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:window_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_index} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_active} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pane_dead} #{s|\\|\\\\|;s|[$]|\\d|;s| |… %0 @0 0 0 0 40 24 sh /tmp/marked host 3442058 /dev/pts/14 0 2000 2 0 %1 @0 1 1 0 39 24 sh /tmp/marked host 3442541 /dev/pts/16 0 2000 2 2 %2 @1 0 1 0 80 24 sh /tmp/marked host 3442666 /dev/pts/17 0 2000 2 0
  10. if-shell -F #{==:#{version},3.8a} '' libtmux-version-0bf9111f9b2a434987384cebcf81f5fa ; list-clients -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:client_name} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:client_pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:client_created} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:session_id} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:client_activity}' no output
  11. if-shell -F #{==:#{version},3.8a} '' libtmux-version-e8d63025cf4f442a97a847cff9a36933 ; display-message -p -F '#{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:pid} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:start_time} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:version} #{s|\\|\\\\|;s|[$]|\\d|;s| |\\t|;s| |\\n|:socket_path}' 3441885 1793890630 3.8a /tmp/libtmux-julia-AbC123/s

sessions returned Selection{SessionSnapshot}

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

The call sent no tmux command.

windowlinks returned Selection{WindowLink}

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

The call sent no tmux command.

window returned Vector{WindowSnapshot}

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

The call sent no tmux command.

panes returned Selection{PaneSnapshot}

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

The call sent no tmux command.

panes returned Selection{PaneSnapshot}

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

The call sent no tmux command.

Snapshot[PaneRef] returned PaneSnapshot

{
"id": "%1"
}

The call sent no tmux command.

window returned WindowSnapshot

{
"name": "editor",
"id": "@0"
}

The call sent no tmux command.

session returned SessionSnapshot

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

The call sent no tmux command.

0/19
Run this example

Julia 1.13.0, Git, POSIX shell and tmux on Linux.

Save the program above as quickstart.jl in a new directory, along with the files below.

Cleanup is omitted; the private tmux server and its temporary files may remain. Select Cleanup to remove them when the program finishes. The program stops its private tmux server and removes any temporary files it created when it finishes. Error handling adds diagnostics; every version checks required results and deadlines.

Setup and run

git init -q source
git -C source fetch -q --depth=1 \
https://github.com/libtmux/libtmux-julia.git \
f2b0fb8e3c4d2e951579e9620cb3396dd5cdc59f
git -C source checkout -q --detach FETCH_HEAD
unset TMUX TMUX_PANE
export ENV=/dev/null BASH_ENV=/dev/null SHELL=/bin/sh
julia --startup-file=no --project=source quickstart.jl

Expected output

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

Install LibTmux

using Pkg
Pkg.activate(".")
Pkg.add(PackageSpec(
    url="https://github.com/libtmux/libtmux-julia.git",
    rev="4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a",
))

Run in Julia with tmux on PATH. The package is not registered in General, so this installs from Git; Manifest.toml records the package tree hash.

MCP

tmux through MCP

Replay Hover a call to preview the tmux state after it. Click to pin it.
tmux window of 1 pane
%0 cat
[docs] 0:cat*

tmux before the first call.

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

tmux after create_session.

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

tmux after send_keys.

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

tmux after list_panes: unchanged, the call only reads.

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

tmux after send_keys_and_wait.

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

tmux after send_keys_and_wait.

tmux window of 1 pane
%0 cat
[docs] 0:cat*

tmux after teardown_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 {"name":"checks","command":["sh"]}
Result
{
"completed": true,
"panes": [
{
"paneId": "%1",
"generation": "3f9a1c"
}
],
"sessionId": "$1",
"generation": "3f9a1c",
"ownership": "application"
}

agentThis server has no split tool, so split from inside the pane the create result returned (%1) with tmux itself.

send_keys {"target":{"paneId":"%1","generation":"3f9a1c"},"keys":["tmux split-window -h sh","Enter"]}
Result
{
"completed": true,
"generationGuarantee": "best_effort",
"target": {
"paneId": "%1",
"generation": "3f9a1c"
}
}

agentList the panes of the session the create result returned ($1); each carries its position and size.

list_panes {"scope":{"sessionId":"$1","generation":"3f9a1c"}}
Result
{
"coverage": "session_scope",
"contextsCoverage": "selected_session",
"terminalContent": "data",
"nextOffset": null,
"pagination": "verified_discovery_facets",
"generationGuarantee": "best_effort",
"panes": [
{
"contextsTruncated": false,
"width": 40,
"caller": false,
"contexts": [
{
"sessionName": "checks",
"windowName": "sh",
"windowIndex": 0,
"sessionId": "$1",
"windowId": "@1"
}
],
"height": 24,
"fieldsTruncated": false,
"title": "host",
"active": false,
"dead": false,
"command": "sh",
"target": {
"paneId": "%1",
"generation": "3f9a1c"
}
},
{
"contextsTruncated": false,
"width": 39,
"caller": false,
"contexts": [
{
"sessionName": "checks",
"windowName": "sh",
"windowIndex": 0,
"sessionId": "$1",
"windowId": "@1"
}
],
"height": 24,
"fieldsTruncated": false,
"title": "host",
"active": true,
"dead": false,
"command": "sh",
"target": {
"paneId": "%2",
"generation": "3f9a1c"
}
}
],
"total": 2,
"nextPageToken": null,
"truncated": false
}

agentRun the tests in the pane the create result returned (%1) and wait for the summary.

send_keys_and_wait {"target":{"paneId":"%1","generation":"3f9a1c"},"keys":["pytest -q","Enter"],"text":"2 passed"}
Result
{
"matched": true,
"source": "output",
"terminalContent": "data",
"evidence": "literal_text",
"continuity": "stream",
"text": "2 passed",
"generationGuarantee": "best_effort",
"keysSent": true,
"target": {
"paneId": "%1",
"generation": "3f9a1c"
}
}

agentShow the log in the new pane the list returned (%2) and wait for its last line.

send_keys_and_wait {"target":{"paneId":"%2","generation":"3f9a1c"},"keys":["cat checks.log","Enter"],"text":"checks finished"}
Result
{
"matched": true,
"source": "output",
"terminalContent": "data",
"evidence": "literal_text",
"continuity": "stream",
"text": "checks finished",
"generationGuarantee": "best_effort",
"keysSent": true,
"target": {
"paneId": "%2",
"generation": "3f9a1c"
}
}

agentRemove the session by the id the create result returned ($1).

teardown_session {"sessionId":"$1","generation":"3f9a1c"}
Result
{
"completed": true,
"sessionId": "$1",
"generation": "3f9a1c"
}
0/6

Install LibTmuxMCP

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

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then register:

$ claude mcp add tmux -- /absolute/path/to/project/bin/libtmux-mcp \
    --socket /absolute/path/to/tmux.sock

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then register:

$ claude mcp add tmux --scope user -- \
    /absolute/path/to/project/bin/libtmux-mcp \
    --socket /absolute/path/to/tmux.sock

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then register:

$ claude mcp add tmux --scope project -- \
    /absolute/path/to/project/bin/libtmux-mcp \
    --socket /absolute/path/to/tmux.sock

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/project/bin/libtmux-mcp",
            "args": ["--socket", "/absolute/path/to/tmux.sock"]
        }
    }
}

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Config file: claude_desktop_config.json

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then register:

$ codex mcp add tmux -- /absolute/path/to/project/bin/libtmux-mcp \
    --socket /absolute/path/to/tmux.sock

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Config file: ~/.codex/config.toml

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

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 = "/absolute/path/to/project/bin/libtmux-mcp"
args = ["--socket", "/absolute/path/to/tmux.sock"]

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then register:

$ gemini mcp add --scope user tmux /absolute/path/to/project/bin/libtmux-mcp \
    -- --socket /absolute/path/to/tmux.sock

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Config file: ~/.gemini/settings.json

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then register:

$ gemini mcp add --scope project tmux \
    /absolute/path/to/project/bin/libtmux-mcp -- \
    --socket /absolute/path/to/tmux.sock

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/project/bin/libtmux-mcp",
            "args": ["--socket", "/absolute/path/to/tmux.sock"]
        }
    }
}

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Config file: .cursor/mcp.json (in repo)

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/project/bin/libtmux-mcp",
            "args": ["--socket", "/absolute/path/to/tmux.sock"]
        }
    }
}

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Config file: ~/.cursor/mcp.json

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then register:

$ grok mcp add --scope user tmux -- /absolute/path/to/project/bin/libtmux-mcp \
    --socket /absolute/path/to/tmux.sock

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Config file: ~/.grok/config.toml

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then register:

$ grok mcp add --scope project tmux -- \
    /absolute/path/to/project/bin/libtmux-mcp \
    --socket /absolute/path/to/tmux.sock

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/project/bin/libtmux-mcp",
            "args": ["--socket", "/absolute/path/to/tmux.sock"]
        }
    }
}

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Build or install the server first:

$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'

Then register:

$ opencode mcp add tmux -- /absolute/path/to/project/bin/libtmux-mcp \
    --socket /absolute/path/to/tmux.sock

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Workspace Manager

Preset
Three panesShort-hand panesTwo panesFour panesMain-horizontal layoutSetup before each paneEnvironmentStart directorySynchronized panesBlank panesVariables in valuesFocusMain pane height as a percentageShell per paneKeep commands out of historyWindow index

Choose a preset 16

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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/3-pane.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded by the library in a test; the command is not run).

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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/shorthands.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded by the library in a test; the command is not run).

Two panes

A window of two panes.

session_name: 2-pane-vertical
windows:
- window_name: my test window
panes:
- echo hello
- echo hello
{
"session_name": "2-pane-vertical",
"windows": [
{
"window_name": "my test window",
"panes": [
"echo hello",
"echo hello"
]
}
]
}
Window 0, my test window: 2 panes, even-vertical❯ echo hello❯ echo hello
no layout set

Workspace file: packages/LibTmuxWorkspace/test/fixtures/tmuxp/2-pane-vertical.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/4-pane.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/main-pane-height.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded by the library in a test; the command is not run).

Setup before each pane

shell_command_before runs ahead of a pane's own commands, at the session, window or pane level.

session_name: dev-${PROJECT}
start_directory: ./src
shell_command_before: echo session
environment:
COMMON: session
SESSION: yes-string
windows:
- window_name: api
start_directory: service
shell_command_before: echo window
environment:
COMMON: window
WINDOW: inherited
panes:
- start_directory: ../tools
shell_command_before: echo pane
shell_command:
- echo ${PROJECT}
- cmd: literal
enter: false
- environment:
COMMON: pane
shell_command: echo ${UNKNOWN}
{
"session_name": "dev-${PROJECT}",
"start_directory": "./src",
"shell_command_before": "echo session",
"environment": {
"COMMON": "session",
"SESSION": "yes-string"
},
"windows": [
{
"window_name": "api",
"start_directory": "service",
"shell_command_before": "echo window",
"environment": {
"COMMON": "window",
"WINDOW": "inherited"
},
"panes": [
{
"start_directory": "../tools",
"shell_command_before": "echo pane",
"shell_command": [
"echo ${PROJECT}",
{
"cmd": "literal",
"enter": false
}
]
},
{
"environment": {
"COMMON": "pane"
},
"shell_command": "echo ${UNKNOWN}"
}
]
}
]
}
Window 0, api: 2 panes, even-vertical❯ echo ${PROJECT}❯ literal❯ echo ${UNKNOWN}
no layout set

Workspace file: packages/LibTmuxWorkspace/test/config.jl. Tested by explicit expansion and inheritance (packages/LibTmuxWorkspace/test/config.jl; loaded 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/session-environment.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/start-directory.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/2-pane-synchronized.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/blank-panes.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/env-variables.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/focus-window-and-panes.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded by the library in a test; the command is not run).

Main pane height as a percentage

main-pane-height takes a percentage of the window as well as a row count.

session_name: main-pane-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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/main-pane-height-percentage.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/pane-shell.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/suppress-history.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; 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: packages/LibTmuxWorkspace/test/fixtures/tmuxp/window-index.yaml. Tested by tmuxp example catalog (packages/LibTmuxWorkspace/test/config.jl; loaded by the library in a test; the command is not run).

Install LibTmuxWorkspace

The workspace package is separate from the core library.

using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "4ff1a9b077bb505a1d8a97a222ffa0d01c9f363a"
Pkg.add([
    PackageSpec(url=repo, rev=ref),
    PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxWorkspace"),
])

Run in Julia. Neither package is registered in General, so this installs from Git. Add the core and workspace packages in one call so both use the same revision.

Build the workspace from a program
packages/LibTmuxWorkspace/examples/owned_load.jl
config = validate(
Dict(
"session_name" => "workspace-example",
"options" => Dict("default-shell" => "/bin/sh"),
"windows" => [
Dict(
"window_name" => "editor",
"window_index" => 0,
"layout" => "even-horizontal",
"focus" => true,
"panes" => [
Dict(
"shell_command" => [
Dict("cmd" => "printf ready", "enter" => false),
],
),
Dict("focus" => true),
],
),
],
),
)
prepared = plan(expand(config; base_directory=dirname(server.socket_path)))
result = apply(server, prepared; rollback=:created)
@assert result.status == :complete

Excerpt of packages/LibTmuxWorkspace/examples/owned_load.jl, which dev/check-matrix.py run runs in the repository's CI (.github/workflows/julia.yml).

Packages and integrations

API references

All Julia versions and install instructions

Esc

Type to search.

Reference previewOpen reference