5

I thought that in tmux, the list of sessions (<prefix>-s) is always automatically sorted alphabetically. I seem to remember this being so always. I create my sessions with names specifically taylored to this assumption.

Lately, when I accidentally close a session and recreate it, it appears at the bottom of the list, which breaks muscle memory.

enter image description here

How can I configure tmux (version 3.1b) to sort sessions alphabetically?

1 Answer 1

8

Seems like tmux in versions ≤ 2.9a sorted sessions alphabetically, but starting from 3.1b this behavior changed.

You can see what <prefix>-s is bound to using the list-keys command. At the time of writing the default is choose-tree -Zs.

From tmux(1):

choose-tree [-GNrswZ] [-F format] [-f filter] [-O sort-order] [-t target-pane] [template]

    Put a pane into tree mode, where a session, window or pane may be chosen interactively from a list. [...]
    -s starts with sessions collapsed.
    -Z zooms the pane.
    [...]
    -O specifies the initial sort field: one of ‘index’, ‘name’, or ‘time’ (activity).

You can rebind the key to whatever you like. In your case, adding the following line to ~/.tmux.conf should be sufficient:

bind s choose-tree -Zs -O name
1
  • After over a decade of use, this was a major shock to me when they changed the behavior to this. Argh.
    – eduncan911
    May 14, 2021 at 15:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .