Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show default (UTC) time as well as IST in tmux statusbar #1

Closed
santosh opened this issue Apr 8, 2021 · 10 comments
Closed

Show default (UTC) time as well as IST in tmux statusbar #1

santosh opened this issue Apr 8, 2021 · 10 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@santosh
Copy link
Owner

santosh commented Apr 8, 2021

No description provided.

@santosh santosh added enhancement New feature or request good first issue Good for newcomers labels Apr 8, 2021
@himanshu007-creator
Copy link
Contributor

i would like to work . Please guide me further

@santosh
Copy link
Owner Author

santosh commented Apr 8, 2021

@himanshu007-creator If you happen to use tmux, I maintain a config file at https://github.com/santosh/.dotfiles/blob/master/.tmux.conf.

Right now, at the low right, the time shown is in local time (configured while installing OS). This used to work fine in my local install.

image

But nowadays most of the time in tmux is in the cloud. I could configure my cloud instance to use IST, but that's not best practice and would lead to confusion.

For this task you could research on tmux status bar customization. And for the getting the text to the statusbar, I hope you could use some Bash or Python script.

Hint: If you are using date command to fetch time in IST, you can do TZ=Asia/Kolkata date.

Let me know how it goes.

@himanshu007-creator
Copy link
Contributor

i will try my best to work on it :-)

@himanshu007-creator
Copy link
Contributor

set -g status-right '#(TZ="Asia/Kolkata" date +%%H:%%M:%%S)'
this piece of code will do the trick. I need to paste it Here right?

@santosh
Copy link
Owner Author

santosh commented Apr 9, 2021

Yes, you are correct about the file.

Also, make sure that I want both times. Separate them by |. Post a screenshot in the PR so I can see.

Edit: Please note that if I use this config in my local installation (configured at installation as IST), it should show the same time in both. The key point to note is the first time shown will be systems local. The second one will be dynamic. I hope you understand. Let me know if there is any concern.

@himanshu007-creator
Copy link
Contributor

himanshu007-creator commented Apr 9, 2021

Yes, you are correct about the file.

Also, make sure that I want both times. Separate them by |. Post a screenshot in the PR so I can see.

Edit: Please note that if I use this config in my local installation (configured at installation as IST), it should show the same time in both. The key point to note is the first time shown will be systems local. The second one will be dynamic. I hope you understand. Let me know if there is any concern.

I am clear about your requirement but I am unable to figure it our. What exactly do I need to do now.
What I think is that, I can display one time as costom Time and second time in custom text field.
I would like if you can help me out here.

@santosh
Copy link
Owner Author

santosh commented Apr 9, 2021

Well, this is weird.

These commands work fine in bash.

ec2-user at ip-172-31-45-160 in ~ $ date +%H:%M:%S                                                 
11:58:47
ec2-user at ip-172-31-45-160 in ~ $ TZ=Asia/Kolkata date +%H:%M:%S                                 
17:29:05

But this config:

set -g status-right '#(date +%%H:%%M:%%S) | #(TZ="Asia/Kolkata" date +%%H:%%M:%%S)'

Renders the same time:

image

Is your output any different @himanshu007-creator?

@santosh
Copy link
Owner Author

santosh commented Apr 10, 2021

I had to force reload the config. I was trying to exit tmux and start again to load the config which didn't work.

@himanshu007-creator You can go ahead and raise the PR.

@himanshu007-creator
Copy link
Contributor

set -g status-right '#(TZ="Asia/Kolkata" date +%%H:%%M:%%S)'
this piece of code will do the trick. I need to paste it Here right?

With this additional line only right?

@santosh
Copy link
Owner Author

santosh commented Apr 10, 2021

While I was researching on the issue, I found this simple theme.

set -g status-bg black
set -g status-fg white
set -g window-status-current-bg white
set -g window-status-current-fg black
set -g window-status-current-attr bold

For the content of the status bar, here are the left and right status bar.

set -g status-left-length 30
set -g status-left '#[fg=green](#S) #(whoami)'
set -g status-right-length 40
set -g status-right "#[fg=white]#S #I:#P #[fg=yellow]:: [%d %b |#[fg=cyan] #(TZ=UTC date -u +%%H:%%M) UTC | #(TZ=Asia/Kolkata date +%%H:%%M) IST]"

For now, you can put the above configs and go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants