fcambus / ansiweather Goto Github PK
View Code? Open in Web Editor NEWWeather in terminal, with ANSI colors and Unicode symbols
License: BSD 2-Clause "Simplified" License
Weather in terminal, with ANSI colors and Unicode symbols
License: BSD 2-Clause "Simplified" License
Hi all.
Made the following .ansiweatherrc
location:Pune,IN
fetch_cmd:ftp -V -o -
symbols:false
forecast:5
#dateformat:%d-%m-%Y
I thought it's possible that the dateformat is malformed or something and that's why it wasn't working.
This is the error it generates :-
$ ansiweather
parse error: Invalid literal at line 1, column 4
ERROR : Cannot fetch weather data for the given location
The file ~/.ansiweatherrc contains the following:
location:4256038
fetch_cmd:ftp -V -o -
units:imperial
show_daylight:true
forecast:5
symbols:true
show_humidity:true
And I get the error
ERROR: Cannot fetch weather data for the given location
Hi -
When running ansiweather, I am getting a whitespace as the first character on the first line of output.
$ansiweather
Weather in London 58 °F
Wind 11.41 mph E
Humd 67 %
Pres 30.21 inHg
SunR May 18 05:03
SunS May 18 20:51
Also, is there a way to override the "Weather in" text and just have "Temp" for the output?
Edit: Bash 4.4.19 on Mac High Sierra, if that makes any difference.
ansiweather's output doesn't fit in a standard 80-column terminal. This could be solved if I could turn off parts of the output that I'm not interested in:
Hey, thanks for making this!
I just give it a try, replacing http: with https: everywhere and the script still works fine. Any reason to not switch over?
Thanks!
-r
URL being requested is actually akin to http://api.openweathermap.org/data/2.5/weather?q=San%20Francisco,US because when units isn't an expected value, it defaults to something totally unusable.
For instance, the above URL currently returns data that San Francisco, CA is 282 degrees (url: http://up.jeremiak.com/S4Yj)
This will show more accurate icons. I suggest the following (compare the API doc), which are all included in the Nerd Fonts:
01d 01n
02d 02n
03d 摒 03n 摒
04d 04n
09d 09n
10d 10n
11d 11n
13d 13n
50d 50n
Hi, i am Brigo, the ansiweather Debian package maintainer.
The descriptions says ansiweather supports ftp, curl or wget, but it just support curl. It would be fine it support at least wget.
If not modify the Requirements section, Thanks.
P.D. ansiweather is already in sid, i have 3 bug in few hours. :-D
https://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=ansiweather;dist=unstable
If a user wants to use data from a different service like Forecast.io, he/she should be able to supply the proper credentials to make it work.
Hello,
As of today I could not get the weather, jq was outputting its cryptic parse error: Invalid numeric literal at line 1, column 8
error message.
This is what curl is getting back from a call to http://api.openweathermap.org/data/2.5/weather?q=Fremont,CA,US&units=metric
Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.
Looks like you need to register an API key now.
Thanks,
Clément
Hi there
I'm getting the error "ERROR: Cannot fetch weather data" if my location in my ansiweatherrc was location:Detroit,MI
I went out on a limb and added a space
location:Detroit, MI
and it worked. Not sure if you can document this or provide more error details or workaround? Thanks for the great tool :)
I live in Kuala Lumpur, Malaysia. Setting the location in .ansiweatherrc as "Kuala Lumpur,MY" causes the fetch to openweathermap.org to fail (the spaces are not escaped when passed to the fetch command).
Workaround is to set the location in the rc file as "Kuala+Lumpur,MY" which works as expected.
As you now have two settings which both contain the text fragment "text" parsing confuses the two, prepending ^ in the grep line fixes this:
ret=$(grep "^$1" $config_file | awk -F: '{print $2}')
Hi all,
It would be nice if at the output used terms instead of symbol, this is useful and necessary both from accessibility viewpoint and sharing the content with others who might not have the symbol font/unicode at their end (I am guessing the symbol font is unicode-based).
The city list from weathermap contains a lot of duplicate city names, because they are in different states. This can lead to very strange results in the US and I imagine in other countries with duplicated city names. The telize api provides the latitude and longitude in the response and the openweathermap API also allows for queries to use lat/long instead of city id / city name. It would be nice if you used the lat/long instead of city names.
More information here : http://marc.info/?l=openbsd-ports&m=143202549432068&w=2
Hi,
I would like have many rc config file. I have already fixed this issue.
I have also added a config for change default color.
My patch :
diff --git a/ansiweather b/ansiweather
index 6bdc60b..b4ad6a7 100755
--- a/ansiweather
+++ b/ansiweather
@@ -19,7 +19,12 @@
LC_NUMERIC=C
-config_file=~/.ansiweatherrc
+if [ $# -gt 0 ]
+then
+ config_file=$1
+else
+ config_file=~/.ansiweatherrc
+fi
function get_config {
ret=""
@@ -110,6 +115,7 @@ done
#### [ Colors and characters ]#################################################
+initialize_color=$(get_config "initialize_color" || echo "\033[0m")
background=$(get_config "background" || echo "\033[44m")
text=$(get_config "text" || echo "\033[36;1m")
data=$(get_config "data" || echo "\033[33;1m")
@@ -348,7 +354,7 @@ then
output="$output$dashes "
fi
done
- output="$output\033[0m"
+ output="$output$initialize_color"
echo -e "$output"
else
if [ $symbols = true ]
@@ -362,7 +368,7 @@ else
output="$output $dashes$text $sunrise_text $delimiter$data $sunrise_time $dashes$text $sunset_text $delimiter$data $sunset_time"
fi
- output="$output \033[0m"
+ output="$output$initialize_color"
echo -e "$output"
fi
Sorry for my english,
Marc
/questions/11740/-/11741 # 11741
I'm on OSX, installed through Homebrew. If I run from the command line, it works fine. But if I put the command in my crontab, I get this error even though I do have jq
installed.
Is this possibly an issue with where Homebrew installs binaries? Why can't it find the jq
binary?
Hello, my name is Thomas and i am not used to github and cmd that much i need this nice tool for a project. I just need to change the default settings specifically the location. I open the ansiweatherrc.example with nano and type location:Corfu,GR and then save it. When i run the command ansiweather
it just displays the default location again and not mine. Am i doing something wrong? (I just need to change the default settings in order not to use location -l command).
Thank you!
I used to use the following command to get the weather in New Orleans, Louisiana, USA:
ansiweather -l New_Orleans,LA
This now returns ERROR: Cannot fetch weather data
This error appears no matter what format I use (quotes, backslash to escape the space, US instead of LA, etc.)
I've used the openweathermap city ID as a workaround, but it's unfortunate that some variation of the actual city name can't be used for multi-word cities.
when running the command with default, i see the standard wind & temp & humidity data. when i rerun with my rc file, i get the options i've specified, but not the default info. are the two outputs mutually exclusive? i've opened up the code, but it might be above my skill level. is there a way to combine the two outputs, e.g.:
Current weather in Yourtown => 76 °F ☔ - Wind => 3.89 mph SE - Humidity => 94 % - Pressure => 30.00 inHg
Yourtown forecast =>
Tue Aug 02: 80/74 °F ☔
Wed Aug 03: 80/74 °F ☁
Thu Aug 04: 82/74 °F ☁
Fri Aug 05: 84/73 °F ☔
Sat Aug 06: 90/77 °F ☔
What the title says.
Here is the output I get when running ./ansiweather
:
➜ ansiweather git:(master) ./ansiweather
./ansiweather: line 76: jq: command not found
./ansiweather: line 77: jq: command not found
./ansiweather: line 78: jq: command not found
./ansiweather: line 79: jq: command not found
./ansiweather: line 80: jq: command not found
./ansiweather: line 81: jq: command not found
./ansiweather: line 82: jq: command not found
./ansiweather: line 90: [: 1382430452: unary operator expected
./ansiweather: line 90: [: 1382430452: unary operator expected
I am running:
➜ ansiweather git:(master) zsh --version
zsh 4.3.10 (x86_64-unknown-linux-gnu)
on:
➜ ~ cat /proc/version
Linux version 2.6.32-358.18.1.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Tue Aug 27 14:23:09 CDT 2013
Hey! Cool little utility.
Perhaps include a --help
or -h
or help
or man ansiweather
feature? :)
/Storm
likely all command line arguments should have precedence over their counterparts in rc files.
Thanks!
If your language doesn't have the same convention that NESW are the directions, you need to change the script itself, which risks getting overwritten in a package update.
If line 240 where you set the wind directions is put into the .ansiweatherrc
and pulled from there, it would be customizable as well.
Same goes for the replacement of the word 'forecast'.
it would be nice if there would be several colorschemes to choose from or even customize it completely.
Hi,
I'm trying to make ansiweather 1.12.0 on macOS output the time and date in an ISO-8601 compatible format.
On Linux, date -I
can be used for outputting an ISO-8601 compatible time and date, but this is not supported on UNIX or macOS.
I tried the following in ~/.ansiweatherrc
:
dateformat:%Y-%m-%d
timeformat:%H:%M
(based on this stackoverflow answer).
The date looks right, but I am unable to see if the timeformat appears correctly.
Feature request: Could there be an option for only using ISO-8601 compatible time and dates?
Thanks for creating ansiweather.
Best regards,
Alexander F. Rødseth
ftp support has been removed in High Sierra.
line 171: ftp: command not found
ERROR: Cannot fetch weather data
I'm working in a Cygwin Shell on a Windows 7 System behind a proxy. Running ./ansiweather
results in the following error:
ERROR : Cannot fetch weather data
It seems there are not options to pass proxy settings. So I suggest to evaluate the environment variables HTTP_PROXY
and HTTPS_PROXY
.
First, great script!
Adding "San Jose,CA" fails where any city w/out a space works like a champ.
Thanks,
$ ./ansiweather
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
./ansiweather: line 90: [: 1382381697: unary operator expected
./ansiweather: line 90: [: 1382381697: unary operator expected
Current weather in => °C - Humidity => % - Pressure => hPa
My .ansiweatherrc looks like this:
cat /.ansiweatherrc/ansiweather$
location:Moscow,RU
fetch_cmd:ftp -V -o -
units:metric
blutgens@sputnik:
~/ansiweather$ jq --version
jq version 1.2
./ansiweather -l Augustow -u metric -s true -k .... -i true -w true -h true -p true -d true
ERROR: Cannot fetch weather data
what could go wrong? where to check it?
why no man page? it would really help.
thanks
If the city name returned by telize has a space in it, the URL to connect to openweathermap is wrong and the result is unparseable by jq. This also happens if the location name in .ansiweatherrc has a space in it. For example, set location to "Sea Cliff,US".
Hi,
I live in San Jose, CA. I input "San Jose, CA" in .ansiweatherrc as my location. This is correctly interpreted (San%20Jose,CA) by the OpenWeather API. I have units:imperial set.
This is what I see:
Current weather in San => 307.937 °F ☀ - Humidity => 46 % - Pressure => 987.89 hPa
Temp is a bit high :).
An issue without too much context as I cannot reproduce again (it might be related to the temperature being 0).
(standard_in) 1: parse error
Current weather in => 0 °C - Wind => m/s N - Humidity => % - Pressure => 0 hPa
~/.ansiweatherrc
location:Stockholm,SE
units:metric
symbols:true
You have to enter Los Angeles as losangeles to avoid this problem despite it being listed on the city page as "Los Angeles." Additionally entering cities as multiple words ignores the rest of the entry, defaulting the output to current weather (not forecast) and metric.
For example:
ansiweather -l Los Angeles,US -u imperial -s true -f 5 -d true
gives the output Current weather in Kingdom of Sweden => 7 °C ☀ - Wind => 1.47 m/s NW - Humidity => 50 % - Pressure => 988 hPa
whereas ansiweather -l losangeles,us -u imperial -s true -f 5 -d true
or ansiweather -l "Los Angeles",us -u imperial -s true -f 5 -d true
(although the latter seems slower on my end) gives the output Los Angeles forecast => Sun Apr 10: 67/57 °F ☔ - Mon Apr 11: 66/52 °F ☔ - Tue Apr 12: 70/43 °F ☀ - Wed Apr 13: 68/44 °F ☀ - Thu Apr 14: 60/48 °F ☔
.
Even if this is not fixed, it would be great if it could be better explained in the README.
Hey, I love this little app, would it be possible to add a simple switch that could display the output of each field on a new line?
Hi, I created Awesome package manager and I can install your repo using it.
After installing the Awesome:
awesome install fcambus/ansiweather
If you can put it in your README, it will be awesome.
Thanks.
Shin
Would it be possible to add an option to use symbols for the separation between directories in the current path? I attached a screen shot that I found, I'm not sure how the look was achieved in the screen shot.
(I apologize if this is already possible. I couldn't seem to find anything documenting this, although I didn't really know what to search.)
My locale is set to nl_NL.UTF-8 and we use comma's for decimal numbers.
For example: we use 18,5 instead of 18.5
This will cause this error:
./ansiweather: line 77: printf: 18.453: invalid number
Solution: put this line somewhere near the start:
LC_NUMERIC=C
This may also prevent errors if you want to use latitude and longitude in the future.
This tool is fantastic, but I struggle heavily reading the results, especially with the blue background.
Is there a possibility to modify the colors?
I'd also like to mention that the following is no good solution for readability as well
-a value Toggle ANSI colors display ( true or false )
It'd be best for readability if only the background disappeared instead of all the colors.
hi there.
Android 6.0.1_r22,
running the script in termux https://play.google.com/store/apps/details?id=com.termux&hl=de
Any hint, what is going wrong?
Could it be the font, or something with the escape sequences?
edit: i've had seen the text alternative, if i'll be unable to solve it ;) #77
Kind regards
Looks like the script uses BSD date options,
ansiweather -f 5
date: invalid option -- 'j'
Try 'date --help' for more information.
date: invalid option -- 'j'
Try 'date --help' for more information.
date: invalid option -- 'j'
Try 'date --help' for more information.
date: invalid option -- 'j'
Try 'date --help' for more information.
date: invalid option -- 'j'
Try 'date --help' for more information.
Istanbul forecast => : 17/15 °C ☁ - : 15/12 °C ☔ - : 16/12 °C ☀ - : 16/13 °C ☀ - : 17/11 °C ☀
In the following please ignore the bold fonts: I didn't find an option to disable Markdown tags.
Pulled and used ansiweather version is from today, 2017-11-02
$ diff -u ansiweatherrc.example ~/.ansiweatherrc
--- ansiweatherrc.example 2017-11-02 14:06:30.357657188 +0100
+++ /home/[deleted-username]/.ansiweatherrc 2017-11-02 16:03:33.113102106 +0100
@@ -2,17 +2,17 @@
api_key:85a4e3c55b73909f42c6a23ec35b7147
fetch_cmd:curl -sf
-location:Rzeszow,PL
+location:Stuttgart,DE
units:metric
forecast:0
ansi:true
-symbols:false
+symbols:true
show_wind:true
-show_humidity:true
-show_pressure:true
-show_daylight:false
+show_humidity:false
+show_pressure:false
+show_daylight:true
dateformat:%a %b %d
-timeformat:%b %d %r
+timeformat:%b %d %R
background:\033[44m
========================
./ansiweather -l Rzeszow,PL -u metric -s false -d true
\033[44m\033[36;1m Weather in Rzeszow \033[35m=>\033[33;1m 8 °C \033[34m-\033[36;1m Wind \033[35m=>\033[33;1m 9.8 m/s SW \033[34m-\033[36;1m Sunrise \033[35m=>\033[33;1m Nov 02 06:24 \033[34m-\033[36;1m Sunset \033[35m=>\033[33;1m Nov 02 16:05
or:
$ ./ansiweather -l Rzeszow,PL -u metric -s true -f 5 -d true
\033[44m\033[36;1m Rzeszow forecast \033[36;1m\033[35m=> \033[36;1mThu Nov 02: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[37;1m\xe2\x98\x94 \033[34m- \033[36;1mFri Nov 03: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[37;1m\xe2\x98\x94 \033[34m- \033[36;1mSat Nov 04: \033[33;1m10\033[36;1m/\033[33;1m5 °C \033[33;1m\xe2\x98\x80 \033[34m- \033[36;1mSun Nov 05: \033[33;1m9\033[36;1m/\033[33;1m5 °C \033[37;1m\xe2\x98\x81 \033[34m- \033[36;1mMon Nov 06: \033[33;1m9\033[36;1m/\033[33;1m3 °C \033[37;1m\xe2\x98\x94
]$
or
./ansiweather -a false -l Rzeszow,PL -u metric -s true -f 5 -d true
\033[44m\033[36;1m Rzeszow forecast \033[36;1m\033[35m=> \033[36;1mThu Nov 02: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[37;1m\xe2\x98\x94 \033[34m- \033[36;1mFri Nov 03: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[37;1m\xe2\x98\x94 \033[34m- \033[36;1mSat Nov 04: \033[33;1m10\033[36;1m/\033[33;1m5 °C \033[33;1m\xe2\x98\x80 \033[34m- \033[36;1mSun Nov 05: \033[33;1m9\033[36;1m/\033[33;1m5 °C \033[37;1m\xe2\x98\x81 \033[34m- \033[36;1mMon Nov 06: \033[33;1m9\033[36;1m/\033[33;1m3 °C \033[37;1m\xe2\x98\x94
]$ ./ansiweather -a false -l Rzeszow,PL -u metric -s false -f 5 -d true
\033[44m\033[36;1m Rzeszow forecast \033[36;1m\033[35m=> \033[36;1mThu Nov 02: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[34m- \033[36;1mFri Nov 03: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[34m- \033[36;1mSat Nov 04: \033[33;1m10\033[36;1m/\033[33;1m5 °C \033[34m- \033[36;1mSun Nov 05: \033[33;1m9\033[36;1m/\033[33;1m5 °C \033[34m- \033[36;1mMon Nov 06: \033[33;1m9\033[36;1m/\033[33;1m3 °C
]$
This is happening on Fedora 26, linux 4.13.9-200.fc26.x86_64, GNOME Terminal 3.24.2, GNOME Shell 3.24.3.
Installed today:
jq-1.5-6.fc26.x86_64
oniguruma-6.4.0-1.fc26.x86_64
I logged out of X/Gnome and in again after the the jq/oniguruma install. But didn't reboot.
bc.x86_64 version is 1.06.95-18.fc26
And similar results as above with an xterm XTerm(327) on the same Gnome/Fedora environment.
HTH
Wolfgang
Not sure how this would happen, but the temperatures I'm seeing in my terminal:
% ansiweather -F -l Siren,US
Siren forecast: Tue Jun 16: 80/66 °F ☁ - Wed Jun 17: 79/62 °F ☀ - Thu Jun 18: 76/62 °F ☔ - Fri Jun 19: 75/56 °F ☀ - Sat Jun 20: 65/54 °F ☔
don't seem to match what I see in the OpenWeatherMap web site at https://openweathermap.org/city/5273324:
And unfortunately neither of these are very consistent with weather.com's forecast (seen here through Google's results):
I would chalk this up to uncertainty, but a ten-degree discrepancy in the current day's forecast (it's 10:45 local time here, so the high is only a couple hours in the future) seems like quite a lot to just be model disagreement. Maybe OpenWeatherMap is inconsistent with both itself and the real world right now?
ftp is available by default on *BSD systems and Mac OS X, so users of those systems only need 'jq' as a dependency. On Linux curl needs to be installed anyway so it would just mean switching dependency from curl to ftp.
Some testing should be done on all systems.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.