tmux

how to format timestamp for tmux list-sessions


the timestamp format ( #{t/f/%%y-%%m-%%d %%H#:%%M#:%%S:window_activity})' ) works with display -p, but it failed with ls. Can anyone help me ?

details:

$ format='#{session_name}: #{session_windows} windows (created #{t/f/%%y-%%m-%%d %%H#:%%M#:%%S:window_activity})'

$ tmux ls -F "${format}"
3: 1 windows (created %y-%m-%d %H:%M:%S)
x: 1 windows (created %y-%m-%d %H:%M:%S)
y: 1 windows (created %y-%m-%d %H:%M:%S)
z: 1 windows (created %y-%m-%d %H:%M:%S)

$ tmux display -p -F "${format}"
3: 1 windows (created 25-01-17 22:33:48)

environment

$ sw_vers 
ProductName:        macOS
ProductVersion:     14.7.2
BuildVersion:       23H311

$ tmux -V
tmux 3.5a

Solution

  • The double percent has to be used "if the format is separately being passed through strftime", while here as you use a direct timevariable-to-display from inside the variable brackets, your format is directly passed to strftime.
    display working with both single and double percents is a side effect.

    You can go with single percent for both commands:

    format='#{session_name}: #{session_windows} windows (created #{t/f/%y-%m-%d %H#:%M#:%S:window_activity})'
    tmux ls -F "${format}"
    tmux display -p -F "${format}"
    

    (same 3.5a on a FreeBSD 14.1-RELEASE)