Skip to content

Instantly share code, notes, and snippets.

@tristanoneil
Last active August 29, 2015 14:19
Show Gist options
  • Save tristanoneil/5a3fa47aa51a8cfb3190 to your computer and use it in GitHub Desktop.
Save tristanoneil/5a3fa47aa51a8cfb3190 to your computer and use it in GitHub Desktop.
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
@tristanoneil
Copy link
Author

Dependencies

In get_weather you'll want to replace forecast-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment