Is there any way to re-number or swap tmux sessions, just as you can renumber or swap tmux windows? I can't see any command for it and want to easily switch between certain sessions.
Asked
Active
Viewed 8,456 times
3 Answers
26
The default ordering seems to have changed recently from name to index. If you want to put it back to name, try this in your .tmux.conf
bind s choose-tree -sZ -O name

Declan Haigh
- 261
- 3
- 4
25
They're sorted by name (which defaults to a number) You can change the names so that they appear in the order that you prefer.
Outside of tmux:
tmux rename-session -t 0 zzz
inside tmux:
C-b $
Or:
c-b : rename session -t current_name new_name

SushiGrass Jacob
- 19,425
- 1
- 25
- 39

Shawn Balestracci
- 7,380
- 1
- 34
- 52
-
4They're not anymore. I named all of my sessions, and they're definitely not alphabetically sorted. – Iulian Onofrei Aug 04 '20 at 09:56
-
11It seems sessions are being ordered by index now (i.e. the order they're created). You can type `O` while in session list mode to cycle through the different sort orderings (including `sort: name`), however I haven't figured out how to persist this setting. – Cody Aug 24 '20 at 17:03
4
If you'd like to "manually" order your sessions, you can prefix the session name with a zero-width or invisible unicode character. For example:
$ tmux rename-session -t charlie $(echo -e "\u200B")charlie
$ tmux rename-session -t beta $(echo -e "\u200C")beta
$ tmux rename-session -t alpha $(echo -e "\u200D")alpha
$ tmux list-sessions
charlie: 1 windows (created Sun Nov 2 12:39:30 2014) [284x87] (attached)
beta: 1 windows (created Sun Nov 2 12:39:27 2014) [284x87]
alpha: 1 windows (created Sun Nov 2 12:39:23 2014) [284x87]
The drawback is that you still have to refer to the session using those characters.

Ben Davis
- 13,112
- 10
- 50
- 65