tmux configuration multiple variables - tmux

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

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.

How to interpolate tmux variable in .tmux.conf?

How to interpolate a variable that was created inside .tmux.conf to be used for a longer command?
I have this in .tmux.conf:
# show window name if set by user
WINDOW_NAME='#{?#{==:#{window_name},#{pane_current_command}},#{pane_current_command},[#{window_name}]:#{pane_current_command}}'
set -g window-status-format $WINDOW_NAME
set -g window-status-current-format $WINDOW_NAME
Now this works fine, as in it shows the window status plus the current window name, but I would like to interpolate this variable something like this:
set -g window-status-format '$WINDOW_NAME > #{=21:pane_title}'
however it does not work, and instead of interpreting the variable it just shows $WINDOW_NAME > user#ip-10...
Assuming the current command was ssh the expected result would be ssh > user#ip-10...

tmux status-line: italicize zoomed window name?

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]'

How do I make Tmux display time in a different time zone?

Hitting <tmuxPrefix> + t displays the time on my server but I want it to display the time in my current timezone rather than the server's timezone.
I run into the same issue when I want to display the time in the status bar in my current timezone.
I was able to partially fix it by using the following command:
set -g status-right '#(TZ="Asia/Kolkata" date )'
But when I use modifiers like %H, %M, %S in the status, as below, it ends up showing the time in the server's time zone.
set -g status-left '%H:%M:%S'
I have updated my .bashrc config with TZ="Asia/Kolkata". This gives me time in the right timezone when I run the time command in bash but it doesn't seem to use the variable in a Tmux session.
Can anyone please let me know how I can fix it?
For the second part of your question, you can use:
set -g status-right '#(TZ="Asia/Kolkata" date +%%H:%%M:%%S)'
What I do is set the timezone for my user.
It works beyond tmux, it will translate anything that displays dates and times, like the output of 'ls' for example.
Edit your ~/.profile and set the TZ variable, for example:
export TZ=/usr/share/zoneinfo/US/Pacific
You can also make ssh send your current timezone automatically. Make sure you have TZ in the ~/.profile of your laptop then instruct ssh to send it by adding this to ~/.ssh/config
SendEnv TZ
The remote server has to be configured to accept it, if it doesn't work make sure it has this in /etc/ssh/sshd_config
AcceptEnv LANG LC_* TZ
If you have white space in the datetime format you can use:
set -g status-right '#(TZ="Asia/Kolkata" date +"%%h %%d %%H:%%M")'

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"

Resources