Skip to content

Instantly share code, notes, and snippets.

@plutozonexyz
plutozonexyz / weather.sh
Last active August 3, 2020 17:07
automated front-end to wttr.in
#!/bin/sh
if [ "$1" == "" ]; then
if [ -f ~/.wttrrc ]; then
curl `echo -n "https://wttr.in/";head -n 1 ~/.wttrrc | tr -d "\n";echo -n "?";head -n 2 ~/.wttrrc | tail -n 1 | tr -d "\n";echo -n "&format=";tail -n 1 ~/.wttrrc | tr -d "\n"`
elif [ -f ~/.config/wttrrc ]; then
curl `echo -n "https://wttr.in/";head -n 1 ~/.config/wttrrc | tr -d "\n";echo -n "?";head -n 2 ~/.config/wttrrc | tail -n 1 | tr -d "\n";echo -n "&format=";tail -n 1 ~/.config/wttrrc | tr -d "\n"`
else
echo "If you are to use weather without a .wttrrc in your ~ (or without a ~/.config/wttrrc), please refer to the '--help' flag for creating a .wttrrc."
fi