An example output with the default format of "tmux ls" is like this below (for me):

$ tmux ls 
26: 1 windows (created Fri Apr 23 10:57:23 2021) [90x30]
27: 1 windows (created Sat Apr 24 01:40:51 2021) [90x30]
28: 1 windows (created Sat Apr 24 01:41:09 2021) [90x30]

Here I want to see the list sorted by the date, but I couldn't find a snippet for that on the internet so I'm trying to learn the format and script by myself. Now for the beginning, I want to know the current format, config used for "tmux ls", and how to check it. I googled SO and checked the document, but couldn't find neither of that how to check or the default format, so I'd like to know is there a way to know them?


So the question here is simply, again, what format (the xxxxx part of tmux ls -F "xxxxx") is being used as the default for tmux ls. This IS the question. (I believe this is quite simple and understandable question...)

  • I think tmux assigns session IDs sequentially. I don't know what the maximal possible ID is; IDK if tmux wraps and reuses old IDs; IDK how extensively you use tmux. If you think you're far from a situation where session IDs are reused then simple tmux ls | sort -n may be enough to show you earlier sessions first. Explicitly sorting by date may not be needed. Commented Jun 1, 2021 at 7:23
  • 1
    I'm not talking about maximum ID. The result is just an example for "tmux ls" output with default format. Actually my "tmux ls" result shows me a tens or hundreds of tmux sessions by the order of 0-9 and a-z. So now, I want to sort the list by the date. I can use awk, sort, and such once I manage to format the result by placing a space between them, so as the post, I'd like to know how to check the default (or script to format and sort by the date if you know) Commented Jun 1, 2021 at 7:35

1 Answer 1


The source code bears the answer in cmd-list-sessions.c (as raw text), the default format is

"#{session_name}: #{session_windows} windows (created #{t:session_created})\
#{?session_grouped, (group ,}#{session_group}#{?session_grouped,),}\
#{?session_attached, (attached),}"

Since you want to sort it, I recommend using a format with #{session_created} so that timestamps are standard Unix time (which is easier to sort).

  • Very nice. Thanks. I made what I wanted to do, sorting by the date (newest order), with: tmux ls -F "#{session_created} #{session_name}: #{session_windows} windows (created #{t:session_created})#{?session_grouped, (group ,}#{session_group}#{?session_grouped,),}#{?session_attached, (attached),}" | sort -Vr | sed 's/\S*\s//' Commented Jun 1, 2021 at 12:00

You must log in to answer this question.

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