I currently use powerline to update contents of my tmux status bar. Powerline reads few environment variables to determine the info for its segments, which get displayed on the tmux status bar.
I need to update the tmux status bar every time, I switch to a different window or a pane, since these environment variables also would likely differ between 2 windows/panes.
I'm aware that the command to update the status bar manually is
One way to update the status bar is to set a low value for
set -g status-interval 1. But this basically invokes powerline once a second, which is overkill for my needs.
Instead what I've currently done is to call
refresh-client every time I switch windows or panes using these keyboard shortcuts:
bind -n C-S-Left previous-window \; refresh-client -S # Previous wind ow bind -n C-S-Right next-window \; refresh-client -S # Next window bind -n M-Up select-pane -U \; refresh-client -S # Up pane bind -n M-Down select-pane -D \; refresh-client -S # Down pane bind -n M-Left select-pane -L \; refresh-client -S # Left pane bind -n M-Right select-pane -R \; refresh-client -S # Right pane
Is there a better way to add a command to be run in tmux, every time the active pane or window is switched ?
The reason I ask is that the above approach has few flaws I notice:
- If I use any other way to switch the active window/pane than the above keys, the status bar would not be refreshed.
- If I exit a window/pane and the active window/pane changes, the status bar will not be refreshed.