1

I want tmux to show pane statuses only when there is more than one pane in the current window. I have currently devised this which will not work when closing all panes but one in a window (meaning one pane will be left but its status won't get hidden):

# Show pane status only when there is more than one pane
set-hook -g window-linked 'set-option -w pane-border-status off'
set-hook -g window-layout-changed 'if-shell -F "#{!=:#{window_panes}, 1}" "set-option -w pane-border-status top" ; if-shell -F "#{==:#{window_panes}, 1}" "set-option -w pane-border-status off"'
set-hook -g window-pane-changed 'if-shell -F "#{!=:#{window_panes}, 1}" "set-option -w pane-border-status top" ; if-shell -F "#{==:#{window_panes}, 1}" "set-option -w pane-border-status off"'
1

White space in tmux formats is significant. The expression "#{==:#{window_panes}}, 1}" is always false because of the space character following the comma.

The following hook works as expected under tmux 2.6 by removing the space from both formats

set-hook -g window-layout-changed 'if-shell -F "#{!=:#{window_panes},1}" "set-option -w pane-border-status top" ; if-shell -F "#{==:#{window_panes},1}" "set-option -w pane-border-status off"'

Alternative hook definition using conditional

set-hook -g window-layout-changed 'set-window -F pane-border-status "#{?#{==:#{window_panes},1},off,top}"'

Conditionals are documented at https://man.openbsd.org/OpenBSD-current/man1/tmux.1#FORMATS

0

I think you almost have it. I had the same question and came up with a simple one line answer (in other words, no need for the three hooks)

is_many="if [ #{window_panes} -eq 1 ]; then exit 1; fi"
set-hook -g window-layout-changed 'if-shell "$is_many" "set-option -w pane-border-status bottom" "set-option -w pane-border-status off"'

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.