tmux status-line: italicize zoomed window name? - tmux

I've customized my tmux statusline, and I'd like to add a visual indicator for when the current window is zoomed (resize-pane -Z).
I've seen several examples of how to apply a different foreground color,
setw -g window-status-current-format " #{?window_zoomed_flag,#[fg=red],#[fg=black]}#W#[fg=default]"
Since I have italics working in tmux, I want to apply them in this case. I tried:
setw -g window-status-current-format " #{?window_zoomed_flag,#[fg=red,italics],#[fg=black]}#W#[fg=default]"
but this doesn't work. When zoomed it just shows empty spaces, and when unzoomed it shows italics],bash ("bash" being the window_name).
It seems to be treating the , in #[fg=red,italics] as one of the separators for the overall conditional form,
#{?test,alternative1,alternative2}
It does correctly handle a comma embedded in alternative2, e.g.
setw -g window-status-current-format " #{?window_zoomed_flag,#[fg=red],#[fg=black,italics]}#W#[fg=default]"
so if I wanted to italicize the unzoomed window name, I'd be in luck, but since I don't have a way to turn the conditional around, I am SOL.
Does anyone know a way to get this working, or is this an issue I should bring to the tmux project?

I got it working and now I'm not sure I actually like it, but it's good to know that it can be done. It's not entirely clear from the documentation, but I noticed in this answer this answer that you can specify the text attribute in a separate #[] group instead of using a comma-separated list, so this works:
setw -g window-status-current-format " #{?window_zoomed_flag,#[fg=red]#[italics],#[fg=black]}#W#[fg=default]"

probably a bit outdated answer yet helpful for anyone out there that might need help!
I have managed to do that with the following code :)
I will post the whole status bar in case anyone finds it any helpfull
set -g status-left '#[fg=black,bg=green] #S#{prefix_highlight}#[fg=green,bg=black,nobold,nounderscore,noitalics]#[fg=green,bg=green]#{?mouse,#[fg=black] MOUSE#[bg=green]#[fg=green],#[bg=red]#[fg=green]#[fg=white]#[bg=red]MOUSE#[bg=green]#[fg=red]}#{?pane_synchronized,#[fg=black] SYNC#[bg=green]#[fg=green],#[bg=red]#[fg=green]#[fg=white]#[bg=red]SYNC#[bg=green]#[fg=red]}#{?window_zoomed_flag,#[fg=black] #[bg=green]#[fg=green],#[bg=red]#[fg=green]#[fg=white]#[bg=red]#[bg=green]#[fg=red]}#[fg=green,bg=black] #W #[fg=green,bg=black,nobold,nounderscore,noitalics]#[fg=green,bg=black] #(whoami) CPU: #{cpu_percentage}Online:#{online_status}#[fg=green,bg=black,nobold,nounderscore,noitalics]'
set -g status-right '#[fg=green,bg=black,nobold,nounderscore,noitalics]#[fg=green,bg=black]#[fg=green,bg=black,nobold,nounderscore,noitalics]#[fg=white,bg=black]Bat: #{battery_percentage}#[fg=green,bg=black,nobold,nounderscore,noitalics]#[fg=black,bg=green]#(rainbarf --battery --remaining )'
setw -g window-status-format '#[fg=green,bg=black,nobold,nounderscore,noitalics]#[default] #I  #W #[fg=green,bg=black,nobold,nounderscore,noitalics]'
setw -g window-status-current-format '#[fg=green,bg=black,nobold,nounderscore,noitalics]#[fg=green,bg=black] #I  #W  #F #[fg=green,bg=black,nobold,nounderscore,noitalics]'

Related

Gruvbox color-scheme not working in tmux-sessoin but working working in normal iterm2

these values are in my tmux-session
I have tried changing these values.
>\# ColorScheme settings.
set -g default-terminal "xterm-256color".
set-option -ga terminal-overrides ",tmux-256color:Tc,xterm256color:Tc"
Adding these lines in the ./tmuxconfig worked.

tmux status line width with unicode characters

I'm running tmux 3.1b on RHEL 7.9.
The following .tmux.conf leads to an expected status line:
$ cat .tmux.conf
set -g status-left "test"
However, if I put a full-with unicode character in the status line:
$ cat .tmux.conf
set -g status-left "👥 test"
The status line seems to be rendered with inappropriate width in the presence of full-width characters, resulting in an overflow onto the next line. Every time tmux refreshes the line, it adds another new line. Anyone have an idea why this might be happening or how to tell tmux to pad the status line less? I did some digging and there are some people complaining of the wrong width for unicode characters in tmux, but I'm not confident that's the problem here.
I'm using mintty 3.4.4 fwiw.
This is probably due to a disagreement between libc, terminal and font about character width. Try building tmux with utf8proc or try a different terminal or font.

tmux configuration multiple variables

Getting errors for the last line. If for status right I only show either spotify or date it works. I cannot get it to show both. What am I missing?
tm_date="#[fg=$tm_color_inactive] %b %d - %I:%M"
tm_session_name="#[fg=$tm_color_feature,bold]$tm_icon #S"
set -g status-left $tm_session_name' '
set -g status-right '#(tmux-spotify-info)' '$tm_date
What is tmux-spotify-info? Is it similar to tm_spotify? If so, changing the line to this seems to fix it.
set -g status-right $tmux-spotify-info' '$tm_date

Renaming a window in tmux

I'm using bind-key + , to rename my windows, but as soon as I type a command the name reverts back to the current working directory.
Is it possible to make the window name permanent?
The automatic rename function is turned on. Add the following to your .tmux.conf file (and/or run from the command line to have it take effect immediately):
set-window-option -g automatic-rename off
Per this superuser answer, I made the following change to ~/.tmux.conf:
# NO, window name keeps changing
# set -g default-terminal "screen-256color"
# YES, window name sticks
set -g default-terminal "xterm-256color"

tmux-powerline is displaying on multiple lines

I posted an issue found at on the github link below, but in short, I can't get zsh to work properly. I'm open to suggestions.
https://github.com/erikw/tmux-powerline/issues/125
Do you have UTF characters in your prompt? If so, make sure you have these settings in your .tmux.conf:
# use UTF8
set -g utf8
set-window-option -g utf8 on
Some UTF characters will take an extra space, causing some weird formatting of tmux-powerline.

Resources