Skip to content

Instantly share code, notes, and snippets.

@sticklerm3
Created April 26, 2020 19:04
Show Gist options
  • Select an option

  • Save sticklerm3/b75e0b6d2e82fa8384d128c61cb389a1 to your computer and use it in GitHub Desktop.

Select an option

Save sticklerm3/b75e0b6d2e82fa8384d128c61cb389a1 to your computer and use it in GitHub Desktop.

Revisions

  1. sticklerm3 created this gist Apr 26, 2020.
    22 changes: 22 additions & 0 deletions zsh-weather-original.zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    zsh_weather(){
    local weather=$(curl -s "https://api.apixu.com/v1/current.json?key="<Your API Key>"&q="<Your City>"")
    local temp=$(echo $weather | jq .current.temp_c)
    local condition=$(echo $weather | jq .current.condition.text)
    #Default value
    local color='%F{green}'
    local symbol="\uf2c7"

    if [[ $condition == *"rain"* ]] ;
    then symbol="\uf043" ; color='%F{blue}'
    fi

    if [[ $condition == *"cloudy"* || $condition == *"Overcast"* ]] ;
    then symbol="\uf0c2" ; color='%F{grey}';
    fi

    if [[ $condition == *"Sunny"* ]] ;
    then symbol="\uf185" ; color='%F{yellow}';
    fi

    echo -n "%{$color%}$temp\u2103 $symbol"
    }