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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With