In a bash script, I want to get the count of windows in current tmux session.

I found tmux display-message -p '#I' get count of pane in current window. But how can I get count of windows instead?

1 Answer 1


#I is not the number of panes in the window, it is the pane index - for number of panes you want '#{window_panes}'.

Similarly, for number of windows in a session you can do '#{session_windows}'.

You must log in to answer this question.

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