brujoand / sbp

Simple Bash Prompt (SBP) is a bash prompt, which strives to be simple. But it isn't. But it looks kind of nice. I think.
MIT License
329 stars 25 forks source link

Fix wttr.in sometimes empty #95

Closed SuperSandro2000 closed 4 years ago

SuperSandro2000 commented 4 years ago

If you have no internet connection and the wttr.in segment gets refreshed it will be an empty segment (only the arrow) until it gets refreshed again.

This checks if the response by wttr.in is empty and does not attempt to write whitespace to the cache.

SuperSandro2000 commented 4 years ago
# (in test file /bash/test/segments/wttr.bats, line 30)
#   `[[ -f "$SEGMENT_CACHE" ]]' failed
# 
# [20.08.07 06:12:10] [wttr.bash - segments::wttr_refresh]: No cache folder
# /bash/src/segments/wttr.bash: line 25: curl: command not found

Not sure why the tests complain about a missing curl.

brujoand commented 4 years ago

Not sure, but I'll take a closer look, and I think I'll start using shfmt for the entire code base btw. Looks like a good compliment to shellcheck.

SuperSandro2000 commented 4 years ago

JFYI: I used shfmt -ci -i 2 -s -w to format this file.