How can I reset tmux's automatic session name numbering?
No, this is not currently possible.
The only thing you can do about this without restarting the server is to override the name manually when creating a new session by issuing tmux new -s 5
, for example:
$ tmux new -d -P
10:
$ tmux ls
10: 1 windows (created Wed Jan 7 15:50:29 2015) [107x89]
$ tmux new -s 5 -d -P
5:
$ tmux ls
10: 1 windows (created Wed Jan 7 15:50:29 2015) [107x89]
5: 1 windows (created Wed Jan 7 15:50:40 2015) [107x89]
$ tmux new -s 5 -d -P
duplicate session: 5
The automatic session number is governed by the global variable u_int next_session_id
in session.c
which cannot be accessed from the command line, as grepping the source code reveals.
tmux new-session
calls session_create()
in session.c
(line 88) and next_session_id
is incremented whenever you create a new session. The argument of -s
flag to new-session
(short new
) sets name
, otherwise next_session_id
is used.
if (name != NULL) {
s->name = xstrdup(name);
s->id = next_session_id++;
} else {
s->name = NULL;
do {
s->id = next_session_id++;
free(s->name);
xasprintf(&s->name, "%u", s->id);
} while (RB_FIND(sessions, &sessions, s) != NULL);
}