4

After accidentally holding down ctrl+alt+t, my tmux sessions are now automatically named with annoyingly high numbers:

llama@llama:~$ tmux ls
124: 1 windows (created Mon Jan  5 16:45:55 2015) [80x24] (attached)

How can I reset this number to 1? I've tried tmux rename-session'ing my session to a lower number, but after closing it and opening a new session, the numbering resumes from the original number.

Is there any way to fix this without restarting tmux?

5

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);
     }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.