Kill a session
Kill a tmux session with kill-session -t =name. A bare name also matches by prefix, so -t work can hit workshop, and the equals sign forces an exact match.
Two sessions have similar names, and killing one by its name must not touch the other.
tmux new-session -d -s work
tmux new-session -d -s workshop
tmux kill-session -t =work
tmux ls -F '#{session_name}'
tmux kill-session -t wor; echo "kill -t wor: $?"
tmux ls; echo "ls: $?"workshop
kill -t wor: 0
no server running on /tmp/tmux-0/default
ls: 1A tmux target such as work is matched against session names first as an exact string and then as a prefix, so -t wor finds workshop when it is the only session that starts that way, and kills it. The = form turns the prefix matching off, as the tmux manual explains under target sessions. In the run, =work removed only work, while the bare prefix removed workshop and left no server running.
When two sessions share the prefix the bare form is rejected as ambiguous, which is the safer failure. A script should therefore always use the equals sign with a name it built itself. kill-server ends every session and the server, which is a bigger hammer than most scripts need.