Hemanth's Scribes

web

Google Sunrise Sunset From Terminal

Author Photo

Hemanth HM

Thumbnail

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

#javascript#linux
Author Photo

About Hemanth HM

Hemanth HM is a Sr. Machine Learning Manager at PayPal, Google Developer Expert, TC39 delegate, FOSS advocate, and community leader with a passion for programming, AI, and open-source contributions.