worldclock.sh 866 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. AS=🌏
  3. EU=🌍
  4. AM=🌎
  5. NIGHT="🌙"
  6. TZONES="America/Los_Angeles America/Denver America/New_York Europe/Amsterdam Asia/Tokyo Australia/Brisbane"
  7. H=`TZ=Europe/Amsterdam date +%H`
  8. if (test $H -gt 2 -a $H -lt 9); then
  9. WORLD=$AS
  10. elif (test $H -gt 9 -a $H -lt 18); then
  11. WORLD=$EU
  12. else
  13. WORLD=$AM
  14. fi
  15. function print_clock() {
  16. TZ=$1
  17. H=$(TZ=$1 date +%H)
  18. COLOR=""
  19. if (test $H -gt 8 -a $H -lt 18); then
  20. echo -n $WORLD
  21. COLOR="\033[1;33m"
  22. else
  23. echo -n $NIGHT
  24. COLOR="\033[1;34m"
  25. fi
  26. if (test $H -gt 5 -a $H -lt 9); then
  27. COLOR="\033[0;33m"
  28. fi
  29. if (test $H -gt 17 -a $H -lt 23); then
  30. COLOR="\033[0;36m"
  31. fi
  32. echo -ne "${COLOR} $1\r\t\t\t\t: "
  33. TZ=$1 date -R
  34. }
  35. while (true); do
  36. clear
  37. for t in $TZONES; do
  38. print_clock $t
  39. done
  40. sleep 61
  41. done