最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

how to format timestamp for tmux list-sessions - Stack Overflow

programmeradmin4浏览0评论

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

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
Share Improve this question edited Jan 23 at 17:44 Guillaume Outters 2,0381 gold badge15 silver badges20 bronze badges asked Jan 18 at 6:35 MarsloMarslo 3,2614 gold badges29 silver badges42 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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)

发布评论

评论列表(0)

  1. 暂无评论