Here’s a quick method to add your local weather report to your tmux status line. First, have a look at the lower right of this screenshot to see what we’re talking about:
Okay, here are the commands we’ll be using, all of which are either already installed or likely available in your favorite package manager:
Here are the steps, assuming everything’s installed:
- Create a small shell script called “gettemp.sh”.
- Add a line to your .tmux.conf file that calls and displays the results of the gettemp.sh script.
- There is no Step 3.
Step 0, however, is to find your local METAR weather code. Don’t know it by heart? For shame! ;) Go to this NOAA/NWS page and drill down to get your four-letter code. We’ll use KLAX for our example.
So, Step 1 — save this code in an executable file in your path:
#!/bin/sh
weather -i KLAX | grep Temperature | sed 's/ Temperature: //g'
There are three parts to this. First, running the weather command, which grabs the online weather report for KLAX. The full report looks like this:
$ weather -i KLAX
Current conditions at Los Angeles Interntl Airport, CA (KLAX)
Last updated Jul 08, 2011 - 01:53 AM EDT / 2011.07.08 0553 UTC
Temperature: 68.0 F (20.0 C)
Relative Humidity: 78%
Wind: from the WSW (240 degrees) at 7 MPH (6 KT)
Sky conditions: clear
Second, the script uses grep to find the line in the report showing the Temperature.
Third, the script removes the “Temperature: ” label, leaving the numerical temperature that we want to display.
Step 2, edit your .tmux.conf file. Now, if you already have a .tmux.conf file in your home directory, you might also have a line that starts set -g status-right — that’s the line we’re going to edit.
Here’s an example .tmux.conf file with a good mix of commands and options set. Find the set -g status-right line, which we’ll use as a starting point.
set -g status-right '#[fg=green]][ #[fg=blue]%Y-%m-%d #[fg=white]%H:%M#[default]'
As you can probably guess, this is showing the Year-month-day in green, then hours:minutes in white. We’ll leave the color alone and put the weather directly after the time thusly:
set -g status-right '#[fg=green]][ #[fg=blue]%Y-%m-%d #[fg=white]%H:%M # // #(gettemp.sh)#[default]'
(Note: this will only work if your gettemp.sh script is in your path; otherwise, you’ll have to specify a full path there.)
And that’s it!


A really cool idea, but there’s one small problem: tmux will execute this script every 15 seconds by default, and therefore make an HTTP call at that interval. Probably not a good idea to beat on the poor NWS servers that often.
I’ve written a bash script that incorporates a small caching mechanism that will only make a new HTTP call every 15 minutes. I’d be happy to share if anyone’s interested. The script also does not depend on the
weatherpackage, onlycurl.@Kevin Otte: I would like to see that script
Anybody know how to use these ideas but to emulate an email notifier? Sort of biff but in the statusbar