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}'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.