Show/Hide Status Line Modules based on window width. Does not work with all modules. #415
-
I like to show/hide specific modules based on how wide my current window width is. It appears with some of the default modules my logic does not work. Specifically those modules where you are required to use "set -agF" vs "set -ag". Working logic: Modules that work with logic:
Non-working logic: Modules that do not work with logic:
Any suggestions appreciated if this is an issues with the modules, or I should perform my logic in a different manner for items where "set -agF" is required. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The problem is, that for these modules the variable must be expanded in order to execute the underlying scripts. To write the statement expanded into the status line, you can use the following statements: set -g status-right '#{?#{>=:#{window_width},101},'
set -agF status-right '#{E:@catppuccin_status_cpu}'
set -ag status-right ',}}' This will result in the following status line: $ tmux show-options -g status-right
status-right "#{?#{>=:#{window_width},101},#[fg=#f9e2af]#[fg=#11111b,bg=#f9e2af] ▐#[fg=#(/home/dreknix/.local/share/tmux/plugins/tmux-cpu/scripts/cpu_fg_color.sh),bg=#(/home/dreknix/.local/share/tmux/plugins/tmux-cpu/scripts/cpu_bg_color.sh)] #(/home/dreknix/.local/share/tmux/plugins/tmux-cpu/scripts/cpu_percentage.sh)#[reverse]█#[noreverse],}}" The statement is still not working since the |
Beta Was this translation helpful? Give feedback.
-
After reading tmux issue #1332 about escaping in conditions, I found this solution: set -g status-right '#{?#{>=:#{window_width},101},#{?,,'
set -agF status-right '#{E:@catppuccin_status_cpu}'
set -ag status-right '},}' I add an additional condition, since in the else part the comma must not be escaped. |
Beta Was this translation helpful? Give feedback.
After reading tmux issue #1332 about escaping in conditions, I found this solution:
I add an additional condition, since in the else part the comma must not be escaped.