tmux has-session exact matching

17 views
Skip to first unread message

Nick Heath

unread,
Aug 8, 2025, 1:04:20 AMAug 8
to tmux-users
Hello, 

I am having problems with a tmux command, has-session <target-session> and finding what looks like a bug, or mismatch with the documentation. I am trying to determine if a named session and window already exists, and if not, start it with a command. 

I am finding that has-session is returning a success when another session window matches the prefix that I am looking for. This should be avoidable with the = qualifier, to require an exact match.

In the man page:

target-session is tried as, in order:
             1.   A session ID prefixed with a $.
             2.   An exact name of a session (as listed by the list-sessions command).
             3.   The start of a session name, for example ‘mysess’ would match a session named ‘mysession’.
             4.   A glob(7) pattern which is matched against the session name.

       If the session name is prefixed with an ‘=’, only an exact match
       is accepted (so ‘=mysess’ will only match exactly ‘mysess’, not
       ‘mysession’).


The following command history demonstrates the behavior that looks incorrect to me. Am I doing something wrong?

/workspace > tmux list-sessions
sheldon: 2 windows (created Thu Aug  7 18:29:49 2025) (attached)

/workspace > tmux list-windows -t sheldon
0: zsh* (1 panes) [198x60] [layout b4bd,198x60,0,0,0] @0 (active)
3: payment-events- (1 panes) [198x60] [layout b4c0,198x60,0,0,3] @3

/workspace > tmux has-session -t sheldon:payment; echo $?
0

/workspace > tmux has-session -t=sheldon:payment; echo $?
0

/workspace > tmux has-session -t=sheldon:fff; echo $?
can't find window: fff
1

I expected the command tmux has-session -t=sheldon:payment to fail with a non-zero exit code, since as you can see, no exact match session names exist. The command generally works, when specifying a session and window name that clearly does not match.

I installed tmux from the system package manager. Here's a little about my environment:

/workspace > uname -a
Linux sheldon-vm 6.10.14-linuxkit #1 SMP Sat May 17 08:28:57 UTC 2025 aarch64 GNU/Linux

/workspace > lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

/workspace > tmux -V
tmux 3.3a

/workspace > cat ~/.tmux.conf
set -g mouse on
set -g history-limit 50000

/workspace > env | grep -i tmux
TERM=tmux-256color
TERM_PROGRAM=tmux
TMUX=/tmp/tmux-0/default,50663,0
TMUX_PANE=%0

Thanks,
Nick

Nicholas Marriott

unread,
Aug 8, 2025, 2:12:04 AMAug 8
to Nick Heath, tmux-users

payment is the window name, not session name, you want =sheldon:=payment



--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/tmux-users/f4eb80a9-6ee6-4c5f-a378-fa4c5644fdd9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages