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")'
Related
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
I've been bashing my head into the wall for some time on this one.
I have a date string in my (ksh) script. It's not the current time, it's some arbitrary time.
How can I convert that date string into a Unix timestamp? I'm working on SunOS 5.10 and AIX, which don't have the date -d option, nor the MacOS date -j -f options.
I only need to do this conversion in one place in my code, so ideally I'd like to do it in one line, but if I have to create a function then so be it
I've messed around with Python and Perl to achieve this in one line. Python came the closest, but I couldn't get it to account for time zone, which I would really like. Any help would be much appreciated.
I lost whatever I had been trying to do with Python earlier, but looking back at it I've found a solution:
python -c 'import datetime, time;print time.mktime(datetime.datetime.strptime("08/22/2014/16", "%m/%d/%Y/%H").timetuple())'
This particular command outputs 1408737600, which is 4pm on August 22 2014 on the east coast.
i have a scenario in which i need to download files through curl command and want my script to pause for some time before downloading the second one. I used sleep command like
sleep 3m
but it is not working.
any idea ???
thanks in advance.
Make sure your text editor is not putting a /r /n and only a /n for every new line. This is typical if you are writing the script on windows.
Use notepad++ (windows) and go to edit|EOL convention|UNIX then save it. If you are stuck with it on the computer, i have read from here [talk.maemo.org/showthread.php?t=67836] that you can use [tr -d "\r" < oldname.sh > newname.sh] to remove the problem. if you want to see if it has the problem use [od -c yourscript.sh] and /r will occur before any /n.
Other problems I have seen it cause is cd /dir/dir and you get [cd: 1: can't cd to /dir/dir] or copy scriptfile.sh newfilename the resulting file will be called newfilenameX where X is an invisible character (ensure you can delete it before trying it), if the file is on a network share, a windows machine can see the character. Ensure it is not the last line for a successful test.
Until i figured it out (i knew i had to ask google for something that may manifest in various ways) i thought that there was an issue with this linux version i was using (sleep not working in a script???).
Are you sure you are using sleep the right way? Based on your description, you should be invoking it as:
sleep 180
Is this the way you are doing it?
You might also want to consider wget command as it has an explicit --wait flag, so you might avoid having the loop in the first place.
while read -r urlname
do
curl ..........${urlname}....
sleep 180 #180 seconds is 3 minutes
done < file_with_several_url_to_be_fetched
?
I have looked at the answers to vi input mode in R? and vi mode to emacs mode while on R. Through the latter question, I learned that meta-ctrl-j will work to toggle vi-mode in R, but I cannot get it to stick so that every time I start R, vi-mode is enabled by default.
I have tried placing set editing-mode vi in my .inputrc, but that does not have the desired effect.
How can I get the vi-mode from meta-ctrl-j to be persistent across R sessions?
Try bind -f ~/.inputrc then bind -V | grep editing-mode and see if you get editing-mode is set to 'vi'.
If that works, it's just a matter of getting that file to be read on login.
Try echo $INPUTRC, if empty set it in your ~/.bashrc. Bash will supposedly check for ~/.inputrc then $INPUTRC then /etc/inputrc in search of your inputrc config.
Additionally, you might try adding bind -f ~/.inputrc to your ~/.bashrc if R opens up an interactive shell.
When I press the prefix-key Ctrl-b tmux doesn't give me a hint that it has been pressed.
Sometimes I can not remember whether I have already pressed it or not.
Can I set up a hint like highlight/change color or show some special symbol in the status bar to show me when I have pressed the prefix-key?
The development version of tmux has support for this, so the next release (1.8?) should also support it.
There have been two changes that can be combined to indicate in your status line whether a prefix key has been pressed:
You can include the extended “format” replacements in the values of the “status” options. These replacements were first available in tmux 1.6, but they were not previously usable in the status options.
The client_prefix format replacement was added.
You could add a (conditional) highlighted <Prefix> string before the default status-right like this:
set -g status-right ' #{?client_prefix,#[reverse]<Prefix>#[noreverse] ,}"#{=21:pane_title}" %H:%M %d-%b-%y'
There's also a Tmux plugin called tmux-prefix-highlight that does this.
It adds a new keyword, #{prefix_highlight} to use in the string that defines your tmux status bar, like so:
set -g status-right '#{prefix_highlight} | %a %Y-%m-%d %H:%M'
I created plugin for this. It indicates copy mode as well, is easily customizable and has good out-of-the-box experience.
https://github.com/dominikduda/tmux_mode_indicator
As readme says:
Plugin indicating normal/insert/prefix/copy modes.
It adds a new keyword, #{tmux_mode_indicator} to use in the string that defines your tmux status bar. Like this:
set -g status-right "#{tmux_mode_indicator}"