Last active
August 29, 2015 14:19
-
-
Save tristanoneil/5a3fa47aa51a8cfb3190 to your computer and use it in GitHub Desktop.
This file contains 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 characters
function fish_greeting | |
set_color green | |
print_weather | cowsay | |
end | |
function print_weather | |
if test -f .weather | |
set time (head -n 1 .weather) | |
set current (date +%s) | |
set diff (math $current - $time) | |
if [ $diff -ge 3600 ] | |
get_weather | |
else | |
echo (sed '2q;d' .weather) | |
end | |
else | |
get_weather | |
end | |
end | |
function get_weather | |
set -l weather (weatherme -k forecast-io-api-key -l 44.6646,-73.0090) | |
printf '%s\n%s' (date +%s) $weather > .weather | |
echo $weather | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dependencies
In
get_weather
you'll want to replaceforecast-io-api-key
with an actual API key which you can obtain from https://developer.forecast.io. You'll also want to set the lat, long unless you happen to live in Fairfax, Vermont.