Google sunrise sunset from terminal

As Google starts Sunrise and Sunset query, i tried these silly bash functions, make it more better.

Prerequisites: curl,html2text
sudo apt-get install curl html2text

$ git clone [email protected]:456310.git and edit.

function sunrise() { curl -sA Mozilla http://www.google.com/search?q=sunrise+$1 \
| html2text -width 80 \
| sed -n '10s/^ \{45\}//p';}

function sunset() { curl -sA Mozilla http://www.google.com/search?q=sunset+$1 \
| html2text -width 80  \
| sed -n '/from now/s/^ \{44\}//p'; }

Paste the above code in your ~/.bashrc or anywhere accessible

Example usage:

hemanth@ubuntu:/tmp$ sunrise bangalore
3 hours 44 minutes from now
hemanth@ubuntu:/tmp$ sunset bangalore
16 hours 37 minutes from now

Do comment you suggestions below

Share this