Check Weather And Surf StackOverflow In Linux Terminal
Table of Contents
Today, let’s have some fun with Linux Terminal. Also, if you’re a developer, let’s reduce one context switch that you make while developing: switching to the browser to look for a solution on StackOverflow. It’s a well-known fact that fewer context switches mean fewer distractions and higher productivity. In this article, we’ll look at two fun and useful things you can do right from the terminal without having to open a browser.
Funny Linux Commands – Check Weather In Linux Terminal
Install curl [optional]Before you can use the API of wttr.in(for weather info), you need to install curl in your system. Install curl
$ sudo apt-get install curl
For Fedora based system –
$ sudo yum install curl
It is not necessary to install curl in order to check the weather in Linux. To obtain weather information, use the wget command, as explained later in this section. This is what we mean when we talk about amusing Linux commands. It increases the productivity of your Linux and teaches you how to use the Linux terminal in other ways.
Linux Weather App Through wttr.in
wttr.in provides api that returns weather information of location in the decorated way. To get weather information –
Open terminal. (shortcut : ctrl + alt + T) and type command : Use wttr.in in terminal –
curl wttr.in
The funny Linux commands display a three-day weather forecast layout for your location, along with the current wind speed. It’s useful when you’re working in terminal and don’t want to leave it. You can easily and quickly check the weather forecast in the terminal.
To check weather forecast of particular place, you can use the command – Check weather forecast of your location
curl wttr.in/location
Example:
curl wttr.in/PaloAlto
To check Moon phase – Check Moon phase
curl wttr.in/Moon
Check Weather In Linux Terminal Using wget Command
curl was required to be installed for the preceding method. If you don’t want to install curl
, you can use the pre-installed wget
command by displaying its output in the terminal. By default, the wget
command saves its output to a file. To get output on the terminal screen, use the -qO-
command line parameter. As an example,
wget -qO- wttr.in/Mumbai
That’s all for the weather API. It’s a small API from wttr.in for the weather forecast in terminal.
Surfing Through StackOverflow In Terminal
Claudio Santini, a London-based developer, had an idea along these lines: why not surf stackoverflow.com directly through terminal? This is exactly what Santini’s opensource project how2 (hosted on github) does. Despite the fact that the wiki page provides installation instructions for how2, let’s take a closer look at this utility.
How To Install How2 To Surf StackOverflow In Terminal
There are a couple of dependencies before installing How2. So let’s fix them first –Install npm Install npm
$ sudo apt-get update
$ sudo apt-get dist-upgrade
Install nodejs
$ sudo apt-get install nodejs
$ sudo npm install -g how2
Do the following changes: Fix issue
ln -s /usr/bin/nodejs /usr/bin/node
How To Use How2 To Surf StackOverflow In Linux
Using how2 is simple as other Linux commands. It takes the following syntax – How2 syntax
how2 [optionaParameter] your Query
If I want to surf how to write if statement in shell script, I would type command:
how2 write if in shell script
It would search and display the result as shown in the screenshot below:
To look for more alternatives hit SPACEBAR. You will see list of other related questions wherein you can select the most relevant to you.
To find answer for a partcular development language you can use -l param.
how2 reverse list -l java
Conclusion
Tools like how2 and the weather API would save you time by eliminating context switching and increasing your productivity. Furthermore, you can obtain the solution on the fly. Continue to investigate the utilities. How2 may not be perfect in all of your queries, but it will undoubtedly help you with 95 percent of them. It saves you from opening a web browser from a technical and development standpoint (also saving eating up of RAM :D). You can also contribute and raise issues on the how2 GitHub project. These were the amusing Linux commands. Please leave any suggestions, comments, or questions in the section below.
LinuxAndUbuntu Newsletter
Join the newsletter to receive the latest updates in your inbox.