Guides
Custom sockets
Target a different tmux server and know when up attaches, switches or only prints the command.
One tmux server is usually enough. Then a CI job needs a session that must never touch your own server, or you want a throwaway server for a gig that you can kill in one go. tmux starts a separate server for each socket, and Glazier follows along with two flags. This page covers the flags and the attach rules that come with them, because where you run glaze up decides what it does at the end.
The flags
| Flag | Description |
|---|---|
--socket-path | The path to a custom tmux socket. Glazier passes it to tmux as -S <path>. |
--socket-name | The name of a custom tmux socket. Glazier passes it to tmux as -L <name>. |
The up, down, ls and save commands accept both flags. format does not talk to tmux and has neither. When you set both flags, Glazier uses --socket-name. Without a flag, Glazier uses the default socket of your tmux.
A named socket lives in the directory that tmux uses for sockets, under TMUX_TMPDIR or /tmp. A socket path is a file path that you choose.
$ glaze up --socket-name gig --detached # build on a second server
$ glaze ls --socket-name gig # list its sessions
$ glaze down --socket-name gig # kill the session there
$ tmux -L gig attach # attach by hand
Use the same flag on every command for that server. glaze down without the flag looks on the default server, finds no session and exits with code 0.
When the socket does not work
Glazier does not treat a socket that gives no access as “no server”. It stops with exit code 4 and shows the tmux error and the tmux command:
$ glaze ls --socket-name glazedoc
tmux is unreachable: error connecting to /tmp/tmux-501/glazedoc (File name too long) (exit status 1, command: /opt/homebrew/bin/tmux -L glazedoc -u list-sessions)
A server that does not run is not an error. ls then writes nothing to stdout and exits with code 0, and down reports that there is nothing to do.
The attach rules
What up does after it builds the session depends on where you run it:
- Outside tmux,
upattaches your terminal to the session. - In a pane of the same tmux server,
upswitches your client to the session. - In a pane of a different tmux server, for example with
--socket-name,updoes not attach, because that would put one tmux client inside another. It shows the command that attaches to the session instead. - Without a terminal, for example in a script,
updoes the same and warns. Use--detachedto skip the warning.
So the common case with a custom socket is the third one: you sit in your usual tmux, run glaze up --socket-name gig, and Glazier hands you a tmux -L gig attach line to run in a fresh terminal. Not glamorous, but the alternative is a tmux inside a tmux, and nobody wants that.
The --clear flag follows the same logic. Glazier refuses --clear when it runs inside the session that it would kill, because the kill would also end Glazier.
Which session am I in
glaze ls lists the sessions on the target server with window counts and starting directories. When you run it in a pane of the same tmux server, Glazier marks the session of that pane with an asterisk:
$ glaze ls
NAME WINDOWS PATH
daemon-run* 3 /home/v/runs/arasaka
scratch 1 /tmp
On a server that you reach through --socket-name from a pane of another server, no session gets the marker, because none of them is yours.
glaze save has the same point of view. Its default is the session of the pane that runs save. Outside a pane of the target server, name the session with --session. See glaze save and Save a running session.