OwnedServer.socket_path
The private socket.
Source and package
- Qualified name
-
libtmux.Owned Server. socket _path - Module
- libtmux
- Declared in
OwnedServer- Package
- libtmux
- Source
- lua/libtmux/_internal/server.lua
-
Examples
Connect a second handle to a running tmux daemon without taking ownership of it. Use Lua 5.1 or newer with LuaRocks, tmux 3.3a or newer, and a C compiler and CMake for luv on Linux. In a new directory, install the library and its standalone runtime dependency from LuaRocks:
Terminal window $ luarocks --tree ./rocks install luv &&luarocks --tree ./rocks install libtmux &&eval "$(luarocks --tree ./rocks path)"Save the complete program as
connect.lua. It starts its own private tmux server, uses it and stops it, so no existing session is needed. View sourceconnect.luaComplete program local adapter = require("libtmux.runtime.luv")local function must(value, err)if err ~= nil thenerror(tostring(err), 0)endreturn valueend-- tmux is /usr/bin/tmux unless TMUX_BIN names another absolute path.local binary = os.getenv("TMUX_BIN") or "/usr/bin/tmux"must(adapter.run(function(runtime)local owned = must(runtime:start_server({ binary = binary }):await())local session = { name = "demo", argv = { "/bin/cat" } }must(owned.server:new_session(session):await())-- A second handle reaches the same daemon and leaves it running on close.local target = { binary = binary, socket_path = owned.socket_path }local server = must(runtime:connect(target):await())local snapshot = must(server:snapshot({ strict = true }):await())local demo = snapshot.sessions:where({ name = "demo" })assert(#demo == 1, "demo session is missing")print("connected")must(server:close():await())must(owned:stop():await())return trueend))Run the saved program. It runs
/usr/bin/tmux; setTMUX_BINto another absolute path to use a different binary. Assertions and operation errors produce a failing exit status:Terminal window $ eval "$(luarocks --tree ./rocks path)" &&lua connect.lua