Skip to content

Instantly share code, notes, and snippets.

@nyimbi
Forked from Goles/cliclock.sh
Created July 29, 2020 07:18
Show Gist options
  • Save nyimbi/19f7e4ade6915d3f8ff6af5e233aa6a3 to your computer and use it in GitHub Desktop.
Save nyimbi/19f7e4ade6915d3f8ff6af5e233aa6a3 to your computer and use it in GitHub Desktop.
Small command line world clock taken from Stack Overflow ( http://stackoverflow.com/questions/370075/command-line-world-clock )
#!/bin/sh
# Command-line world clock
# Taken from http://stackoverflow.com/questions/370075/command-line-world-clock
# .worldclock.zones file looks like:
# US/Pacific
# Europe/Berlin
# Chile/Continental
: ${WORLDCLOCK_ZONES:=$HOME/.worldclock.zones}
: ${WORLDCLOCK_FORMAT:='+%Y-%m-%d %H:%M:%S %Z'}
while true
do
clear
while read zone
do echo $zone '!' $(TZ=$zone date "$WORLDCLOCK_FORMAT")
done < $WORLDCLOCK_ZONES |
awk -F '!' '{ printf "%-20s %s\n", $1, $2;}'
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment