Home Command line utilities How To Get News Instantly From Commandline In Linux

How To Get News Instantly From Commandline In Linux

By sk
Published: Last Updated on 5.3K views

In this Digital era, there are plethora of apps and utilities available to read news from online. Most of them are GUI-based. Fortunately, there is a command line utility to read News for those who live in Terminal all day. Meet "Instantnews" - a simple, yet useful CLI utility to get news from commandline. This utility instantly retrieves all sorts of news and displays them in the Terminal. So, you don't need any GUI applications or don't leave from Terminal or don't even need hard copies to read World news. In this brief tutorial, I will explain how to install "instantnews" and how to get world news right from the Terminal in Unix-like operating systems.

Install Instantnews

The Instantnews utility can be installed either using pip or can directly be compiled and installed from source.

Using PIP:

First, install pip as shown below.

On Arch Linux and its derivatives, run the following command to install pip:

$ sudo pacman -S python-pip

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install python-pip

On RHEL, Fedora, CentOS:

$ sudo yum install python-pip

Or,

$ sudo dnf install python-pip

On SUSE/openSUSE:

$ sudo zypper install python-pip

Once pip is installed, install Instantnews using pip with command:

$ pip install instantnews

Install from source:

To build from source, do the following:

$ git clone https://github.com/shivam043/instantnews.git
$ cd instantnew
$ sudo python setup.py install

Configure Instantnews

Instantnews retrieves all news headlines from News API. For those wondering, News API is a simple and easy-to-use API that returns JSON metadata for the headlines currently published on a range of news sources and blogs. It currently provides live headlines from 70 popular sources, including Ars Technica, BBC, Blooberg, CNN, Daily Mail, Engadget, ESPN, Financial Times, Google News, hacker News, IGN, Mashable, National Geographic, Reddit r/all, Reuters, Speigel Online, Techcrunch, The Guardian, The Hindu, The Huffington Post, The Newyork Times, The Next Web, The Wall street Journal, USA today and more.

First, you need an API key from News API. Go to https://newsapi.org/register URL and register a free account to get the API key.

Once you got the API key from News API site, edit your .bashrc file:

$ vi ~/.bashrc

Add newsapi API key at the end like below:

export IN_API_KEY="Paste-API-key-here"

Please note that you need to paste the key inside the double quotes. Save and close the file.

Run the following command to update the changes.

$ source ~/.bashrc

Get News Instantly From Commandline In Linux Using Instantnews

To display help, run:

$ instantnews -h
usage: instantnews [-h] [--show SHOW] [--show_all] [--news NEWS]

optional arguments:
 -h, --help show this help message and exit
 --show SHOW, -s SHOW Shows all the news channel codes category wise
 --show_all, -sa Shows all the news channel codes
 --news NEWS, -n NEWS Shows news

List all available news channels

Let us see the list of all available news channels.

$ instantnews -sa

Or,

$ instantnews --show_all

Sample output would be:

News Code: <abc-news-au> ABC News (AU)
News Code: <al-jazeera-english> Al Jazeera English
News Code: <ars-technica> Ars Technica
News Code: <associated-press> Associated Press
News Code: <bbc-news> BBC News
News Code: <bbc-sport> BBC Sport
News Code: <bild> Bild
News Code: <bloomberg> Bloomberg
News Code: <breitbart-news> Breitbart News
News Code: <business-insider> Business Insider
News Code: <business-insider-uk> Business Insider (UK)
News Code: <buzzfeed> Buzzfeed
News Code: <cnbc> CNBC
News Code: <cnn> CNN
News Code: <daily-mail> Daily Mail
News Code: <der-tagesspiegel> Der Tagesspiegel
News Code: <die-zeit> Die Zeit
News Code: <engadget> Engadget
News Code: <entertainment-weekly> Entertainment Weekly
News Code: <espn> ESPN
News Code: <espn-cric-info> ESPN Cric Info
News Code: <financial-times> Financial Times
News Code: <focus> Focus
News Code: <football-italia> Football Italia
News Code: <fortune> Fortune
News Code: <four-four-two> FourFourTwo
News Code: <fox-sports> Fox Sports
News Code: <google-news> Google News
News Code: <gruenderszene> Gruenderszene
News Code: <hacker-news> Hacker News
News Code: <handelsblatt> Handelsblatt
News Code: <ign> IGN
News Code: <independent> Independent
News Code: <mashable> Mashable
News Code: <metro> Metro
News Code: <mirror> Mirror
News Code: <mtv-news> MTV News
News Code: <mtv-news-uk> MTV News (UK)
News Code: <national-geographic> National Geographic
News Code: <new-scientist> New Scientist
News Code: <newsweek> Newsweek
News Code: <new-york-magazine> New York Magazine
News Code: <nfl-news> NFL News
News Code: <polygon> Polygon
News Code: <recode> Recode
News Code: <reddit-r-all> Reddit /r/all
News Code: <reuters> Reuters
News Code: <spiegel-online> Spiegel Online
News Code: <t3n> T3n
News Code: <talksport> TalkSport
News Code: <techcrunch> TechCrunch
News Code: <techradar> TechRadar
News Code: <the-economist> The Economist
News Code: <the-guardian-au> The Guardian (AU)
News Code: <the-guardian-uk> The Guardian (UK)
News Code: <the-hindu> The Hindu
News Code: <the-huffington-post> The Huffington Post
News Code: <the-lad-bible> The Lad Bible
News Code: <the-new-york-times> The New York Times
News Code: <the-next-web> The Next Web
News Code: <the-sport-bible> The Sport Bible
News Code: <the-telegraph> The Telegraph
News Code: <the-times-of-india> The Times of India
News Code: <the-verge> The Verge
News Code: <the-wall-street-journal> The Wall Street Journal
News Code: <the-washington-post> The Washington Post
News Code: <time> Time
News Code: <usa-today> USA Today
News Code: <wired-de> Wired.de
News Code: <wirtschafts-woche> Wirtschafts Woche

Like I mentioned already, there are 70 news sources as of writing this guide. More will be added in the days to come. As you see in the above output, all news codes are listed in a single output. You can also display news channels category wise.

List news channels category wise

To display all the news channel codes category wise, run:

$ instantnews --show SHOW <category>

Or,

$ instantnews -s SHOW <category>

The following categories are available.

  • business
  • entertainment
  • gaming
  • general
  • music
  • politics
  • science-and-nature
  • sport
  • technology

Now, to display news channels category wise, say technology, run:

$ instantnews --show technology

Or,

$ instantnews -s technology

Sample output would be:

News Code: <ars-technica> Ars Technica
News Code: <engadget> Engadget
News Code: <gruenderszene> Gruenderszene
News Code: <hacker-news> Hacker News
News Code: <recode> Recode
News Code: <t3n> T3n
News Code: <techcrunch> TechCrunch
News Code: <techradar> TechRadar
News Code: <the-next-web> The Next Web
News Code: <the-verge> The Verge
News Code: <wired-de> Wired.de

Get news instantly from Terminal

To get news headlines from a news channel, say The Hindu, run the following command with correct News code:

$ instantnews --news the-hindu

Or,

$ instantnews -n the-hindu

Now, you will see all news headlines from the given news source i.e The Hindu in our case.

Instantnews

InstantNews in action

Similarly, you can read news any other sources. For example, to read news headlines from Techcrunch, run the following command:

$ instantnews -n techcrunch

Suggested read:


While testing it, I noticed that I can't open any particular news code in my web browser to read more about it. I guess it's a bug. Of course, there is no code without bugs. Hope the developer will fix it and add some new features. This project is very new and is being actively developed. If there are any bugs or feature requests, notify them in the GitHub page given at the end.

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More