Show times in different timezone with bash
grab the shell script directly from this repo and put it in your path, or just copy and paste this :
# will try to install in /usr/local if you have the right or $HOME/.local/bin need to be in your path
dest="/usr/local/bin"
[[ -w ${dest} ]] || { dest=${HOME}/.local/bin;mkdir -p ${dest} ;}
curl -f -L -o ${dest}/batz https://raw.githubusercontent.com/chmouel/batzconverter/master/batz.sh && \
chmod +x ${dest}/batz && \
echo "'The' batz has been installed into: ${dest}/batz"
Create a file in ~/.config/batz/config
and add configure the TIME_ZONES
and TIME_ZONES_EMOJI
variable like this :
## Change the default timezones here!
TIME_ZONES=(
["India"]="Asia/Calcutta"
["Europe"]="Europe/Paris"
["US-East"]="America/New_York"
["US-West"]="America/Los_Angeles"
)
TIME_ZONES_EMOJI=(
["India"]="๐ฎ๐ณ "
["Europe"]="๐ช๐บ "
["US-East"]="๐บ๐ธ "
["US-West"]="๐ป"
)
DATE_FORMAT="%b %Hh%M"
DATE_FORMAT_PADDING=10
DEFAULT_TIME_ZOME_EMOJI="๐"
The format is :
"TZ_Alias_Name"="Timezone"
for example :
"HomeSweetHome"="Europe/Paris"
You can look an example in my config here
Some pretty modern Bash >4.0 and modern GNU Date. On MacosX install those from brew (bash and gnuutils).
% batz
% batz 10h30
% batz 10h30 next week
% batz 11:00 next thursday
BaTZ will show all different timezone for the timeformat
You can as well add multiple timezones directly on the command line like this :
% batz +America/Chicago +UTC 10h00 tomorrow
If you don't know the timezone and you have the
fzf utility installed you can use the -f
option to select interactively the timezone. You can select multiple timezone
by using the TAB
key in fzf.
By default this script will try to detect your current timezone, if you want to say something like this: show me the different times tomorrow if I were at 10h00 AM on UTC timezone, you can do :
% batz -t UTC 10h00
When you set another timezone than your current one, it wil show a nice
If you want to add extra timezone with +TZ you need to do at first before the options, cause bash getopt is kind of buggy in this regard
You can use the -j
option to output as json and may do some parsing with it.
(this is used by the Alfred suppoort).
If you have the gum utility installed
you can use the flag -g
to show the timezone using the gum tables You can as
well set USE_GUM=1
in your config file to set it as default.
The output looks for example like this for me:
You can add the -n
argument to batz to not show any colours or emojis. It
will respect the NO_COLOUR
environment variable as
well.
Rofi Support
Take this rofi script rofibatz.sh and place it somewhere, i.e: ~/.config/rofi/rofibatz.sh
, launch it up like this :
rofi -modi batz:${HOME}/.config/rofi/rofibatz.sh -show batz
You can type batz string i.e: 13h00 tomorrow
when you press enter it will evaluate it.
I have a custom theme so your mileage may vary but for me it will be shown like this :
Wofi Support
Just do something like this assuming you have wofi and wl-copy installed :
wl-copy $(batz|sed -e "s/\x1b\[.\{1,5\}m//g"|wofi -d|sed 's/.* : //')
will only get you the timezone since wofi doesnt support scripts (afaik)
Alfred Support
BaTZ support alfred, it basically output nicely the timezone from alfred in a nice way.
Just install the alfredworlflow file from the repository
and make sure the batz script is in one of these path: $HOME/bin/
or /usr/local/bin/
Zenity support
output=$(zenity --entry --text "๐ฆTime" --entry-text $(date ''+%H:%M''));[[ -n $output ]] && batz $output|wl-copy',
Chmouel Boudjnah <@chmouel>