Skip to content

Commit 1f7f091

Browse files
Merge pull request #320 from wisscot/temperature_in_weather_fix
bug fix: temperature not showing for certain weather info many thanks to @wisscot for his contribution!
2 parents 4a5f262 + cc5e11e commit 1f7f091

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/weather.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ display_weather()
4949
fi
5050
weather_information=$(fetch_weather_information $display_weather)
5151

52-
weather_condition=$(echo $weather_information | rev | cut -d ' ' -f2- | rev) # Sunny, Snow, etc
53-
temperature=$(echo $weather_information | rev | cut -d ' ' -f 1 | rev) # +31°C, -3°F, etc
52+
weather_condition=$(echo "$weather_information" | awk -F' -?[0-9]' '{print $1}' | xargs) # Extract condition before temperature, e.g. Sunny, Snow, etc
53+
temperature=$(echo "$weather_information" | grep -oE '[-+]?[0-9]+°[CF]') # Extract temperature, e.g. +31°C, -3°F, etc
5454
unicode=$(forecast_unicode $weather_condition)
5555

5656
# Mac Only variant should be transparent on Linux

0 commit comments

Comments
 (0)