Skip to content

Instantly share code, notes, and snippets.

@woodrowbarlow
Last active February 27, 2017 14:09
Show Gist options
  • Save woodrowbarlow/9ef19ce5c5d48eddb8f08063aed1b0d9 to your computer and use it in GitHub Desktop.
Save woodrowbarlow/9ef19ce5c5d48eddb8f08063aed1b0d9 to your computer and use it in GitHub Desktop.
Output an analog clock for the current time, using unicode.
#!/bin/bash
# Output an analog clock for the current time.
# Rounded to the nearest half-hour.
(( clock = $(date +"%I") + 143 ))
if [[ $(date +"%M") > 45 ]]; then
(( clock ++ ))
[[ $clock > 152 ]] && (( clock = 144 ))
elif [[ $(date +"%M") > 15 ]]; then
(( clock += 12 ))
fi
echo -e "\xF0\x9F\x95\x$(printf "%02x" $clock)"
#!/bin/bash
# Output an analog clock for the current time.
# Rounded to the most recent half-hour.
(( clock = $(date +"%I") + 143 ))
if [[ $(date +"%M") > 30 ]]; then
(( clock += 12 ))
fi
echo -e "\xF0\x9F\x95\x$(printf "%02x" $clock)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment