Wttr.in: Dark background color

Created on 20 Feb 2016  ·  11Comments  ·  Source: chubin/wttr.in

Any chance of explicitly setting background color of output to dark background color? Visuals can be unreadable on light terminal themes.

screen shot 2016-02-20 at 12 38 17

enhancement

Most helpful comment

One tip, in order to change colors you could alias the wttr.in command on your .bashrc or .zshrc like the following:

alias weather='curl wttr.in/YOUR_CITY | sed -e "s:226m:202m:g"'

where 226m is the yellow color code on 256 colors terminals which is changed with a more readable orange (202m).

the complete list of colors could be reached here

update:
a more comprehensive solution which I'm currently still using is:

_weather() {
    tmpfile=$(mktemp)
    curl -s wttr.in/$1 > $tmpfile
    cat $tmpfile | sed -e 's:226m:202m:g'
    rm $tmpfile
}
alias weather='_weather'

and I use this:

$ weather CITY

All 11 comments

One tip, in order to change colors you could alias the wttr.in command on your .bashrc or .zshrc like the following:

alias weather='curl wttr.in/YOUR_CITY | sed -e "s:226m:202m:g"'

where 226m is the yellow color code on 256 colors terminals which is changed with a more readable orange (202m).

the complete list of colors could be reached here

update:
a more comprehensive solution which I'm currently still using is:

_weather() {
    tmpfile=$(mktemp)
    curl -s wttr.in/$1 > $tmpfile
    cat $tmpfile | sed -e 's:226m:202m:g'
    rm $tmpfile
}
alias weather='_weather'

and I use this:

$ weather CITY

You can reduce it to this:

_weather() {
tmpfile=$(mktemp)
curl -s wttr.in/$1 | sed -e 's:226m:202m:g'
}
alias weather='_weather

@m0veax No, not really! What you did is what the first alias from @alex179ohm already does — pipe curl's output to sed. But, in addition, each time _weather is called you also create a wasteful temporary file (which is not used in your script and even not deleted afterwards).

I also use a light terminal theme so I created a shell script to solve this issue.

weather.sh:

#!/bin/bash

# default location
LOC="${1:-ADD_YOUR_DEFAULT_LOCATION_HERE}"

# force dark background color
esc=$'\e'
bg="$esc[48;5;232m"
eol="$esc[K"

echo -e "$bg$eol"
curl -s "http://wttr.in/$LOC" | sed "s/^/$bg$eol  /;s/\[0m/\[0m$bg/g"
echo -e "$bg$eol"

screen shot 2017-01-17 at 4 05 25 pm

The ANSI escape sequences to set a dark background could be simply sent along with the rest of the text, just like the rest of the color escapes.

@book The issue not about background color per se, the point is to preare a new color scheme, that will good work with the new background

In case anybody simply wants to remove color entirely, I do that with sed 's/\x1B[0-9\[;]\+m//g'

@C4K3 Just use ?T
wttr.in/?T

it should work. Does it work for you?

@chubin It does, awesome, I didn't know about that option.

@chubin Hi,

Sorry to ping on this, but could you make min temperature blue color just a little bit brighter, please? It's so cold here, I can barely distinguish the digits at the low end.

Konsole wttr.in

I'm using Konsole with slightly customized Arc Dark theme, its background color is solid #383c4a.

I've changed it to violet. I think it is better so. You know, if it is -56⁰C outside, I think blue is not blue enough for that, it should be something special

Selection_083

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdigga39 picture mdigga39  ·  4Comments

097115 picture 097115  ·  6Comments

arkylin picture arkylin  ·  9Comments

cjwelborn picture cjwelborn  ·  6Comments

bahamas10 picture bahamas10  ·  10Comments