worldclock.sh 862 B

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