emoji-clock.plugin.zsh 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. # ------------------------------------------------------------------------------
  2. # FILE: emoji-clock.plugin.zsh
  3. # DESCRIPTION: The current time with half hour accuracy as an emoji symbol.
  4. # Inspired by Andre Torrez' "Put A Burger In Your Shell"
  5. # http://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html
  6. # AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
  7. # VERSION: 1.0.0
  8. # -----------------------------------------------------------------------------
  9. function emoji-clock() {
  10. # Add 15 minutes to the current time and save the value as $minutes.
  11. (( minutes = $(date '+%M') + 15 ))
  12. (( hour = $(date '+%I') + minutes / 60 ))
  13. # make sure minutes and hours don't exceed 60 nor 12 respectively
  14. (( minutes %= 60 )); (( hour %= 12 ))
  15. case $hour in
  16. 0) clock="🕛"; [ $minutes -ge 30 ] && clock="🕧";;
  17. 1) clock="🕐"; [ $minutes -ge 30 ] && clock="🕜";;
  18. 2) clock="🕑"; [ $minutes -ge 30 ] && clock="🕝";;
  19. 3) clock="🕒"; [ $minutes -ge 30 ] && clock="🕞";;
  20. 4) clock="🕓"; [ $minutes -ge 30 ] && clock="🕟";;
  21. 5) clock="🕔"; [ $minutes -ge 30 ] && clock="🕠";;
  22. 6) clock="🕕"; [ $minutes -ge 30 ] && clock="🕡";;
  23. 7) clock="🕖"; [ $minutes -ge 30 ] && clock="🕢";;
  24. 8) clock="🕗"; [ $minutes -ge 30 ] && clock="🕣";;
  25. 9) clock="🕘"; [ $minutes -ge 30 ] && clock="🕤";;
  26. 10) clock="🕙"; [ $minutes -ge 30 ] && clock="🕥";;
  27. 11) clock="🕚"; [ $minutes -ge 30 ] && clock="🕦";;
  28. *) clock="⌛";;
  29. esac
  30. echo $clock
  31. }