Skip to content

Instantly share code, notes, and snippets.

@XayOn
Last active December 11, 2015 11:28
Show Gist options
  • Save XayOn/4593333 to your computer and use it in GitHub Desktop.
Save XayOn/4593333 to your computer and use it in GitHub Desktop.
tmux-powerline weather segment written in bash
#!/bin/bash
declare -A tp_weather
tmp_tmp=$(mktemp -d);
tp_weather=(
[location]="779063"
[unit]="c"
[tmp]="${tp_tmp}/weather"
[update_secs]=600
);
(( $(( $(date "+%s") - $(stat -c "%Y" ${tp_weather[tmp]}) )) > 100)) && {
[[ $(curl --max-time 4 -s "http://weather.yahooapis.com/forecastrss?w=${tp_weather[location]}&u=${tp_weather[unit]}") =~ (.*)\<yweather\:forecast(.*)text=\"(.*)\"(.*)code=\"(.*)\"(.*)\/\>(.*) ]] && {
echo ${BASH_REMATCH[5]};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment