Created
December 30, 2015 15:28
-
-
Save zuloo/f2fed0de6ddbc0d25e2e to your computer and use it in GitHub Desktop.
Revisions
-
zuloo created this gist
Dec 30, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #!/bin/bash moonphase(){ local lp=2551443 local now=$(date -u +"%s") local newmoon=592500 local phase=$((($now - $newmoon) % $lp)) local phase_number=$((((phase / 86400) + 1)*100000)) # Multiply by 100000 so we can do integer comparison. Go Bash! if [ $phase_number -lt 184566 ]; then phase_icon="○" # new elif [ $phase_number -lt 553699 ]; then phase_icon="❩" # waxing crescent elif [ $phase_number -lt 922831 ]; then phase_icon="◗" # first quarter elif [ $phase_number -lt 1291963 ]; then phase_icon="◑" # first quarter elif [ $phase_number -lt 1661096 ]; then phase_icon="●" # full elif [ $phase_number -lt 2030228 ]; then phase_icon="◐" # waning gibbous elif [ $phase_number -lt 2399361 ]; then phase_icon="◖" # last quarter elif [ $phase_number -lt 2768493 ]; then phase_icon="❨" # waning crescent else phase_icon="○" # new fi echo $phase_icon } moonphase