How to use Twitter in a Linux terminal with Rainbow Stream

There are many native Twitter clients available on Linux platforms, be it a GUI-based client (e.g., Birdie, Choqok, Gwibber, Turpial) or a terminal-based counterpart (e.g., t or TTYtter client). In the world of open-source software, such diversity is the norm, and the freedom of choice is what we all cherish in Linux.

For those Linux CLI lovers, here is a yet another terminal based Twitter client to add to the list. Rainbow Stream is an open-source Twitter CLI client written in Python. As its colorful name suggests, Rainbow Stream features the ability to display your Twitter feed in a fancy colorful console, which makes browsing your Twitter timeline a more pleasant experience. You can even view images embedded in a tweet directly within a terminal.

In this tutorial, I will describe how to set up and customize Rainbow Stream, as well as demonstrate its commands.

Install Rainbow Stream on Linux

First, make sure that your system has Python v2.7+ or 3.x. A quick installation method is using pip with sudo permission. Install pip on your system if it is not available.

Then use the command below to install Rainbow Stream.

$ sudo pip install rainbowstream

For Python 3 users:

$ sudo pip3 install rainbowstream

If you are familiar with virtualenv, there is a safer way to install it:

$ virtualenv venv
$ source venv/bin/activate
$ pip install rainbowstream

If you are a Python3 user, replace the first command above with 'virtualenv -p /usr/bin/python3 venv'

Authorize Rainbow Stream

When Rainbow Stream is installed correctly, the rainbowstream command will be available. To initiate a one-time authorization process, simply run this command, which will automatically pop up a web browser window for authorization.

$ rainbowstream

On the browser window, log in to your Twitter account, and you will be asked to authorize Rainbow Stream to access your Twitter account. Click on "Authorize app" button.

In the next page, you will see a PIN number generated for Rainbow Stream.

Enter the PIN in the terminal where you are running rainbowstream.

Now you are ready to use Rainbow Stream inside a terminal.

If you are trying to authorize Rainbow Stream on a remote headless server, you can copy and paste the authorization URL to a web browser running on a separate computer.

Theme and Configuration

If you type 'h' at the RainbowStream prompt, it will show you a quick help screen which introduces a set of available commands. Reading this quick help will assist you understand a full list of supported commands. Among them are the global theme and config commands.

The theme command allows you to quickly switch your Twitter timeline color theme among four built-in beautiful themes. Typing "theme" followed by a theme name (available via tab-autocomplete) will change your theme immediately.

To switch to a theme called solarized:

[@dtvd88]: theme solarized

The config command will list all available configuration values. You can change any configuration vale by using config command, or by editing configuration manually in ‘~/.rainbow_config.json’ file.

To see all available configuration options:

[@dtvd88]: config

To set "HIDE_PROMPT" configuration to "true":

[@dtvd88]: config HIDE_PROMPT = true

View Tiwtter Images on a Terminal

The most interesting feature of Rainbow Stream is the ability to view tweet-embedded images directly in a terminal. Launching rainbowstream with parameter "-iot", or changing the config key "IMAGE_ON_TERM" to "true" will enable that feature.

As you can see above, Twitter messages in Rainbow Stream are organized as "threads", which makes it look like a messenger app. To print images to a terminal window, Rainbow Stream uses Pillow as an image processing engine, and fabulous as a display algorithm.

To conclude, Rainbow Stream is a convenient Twitter CLI client which is designed with usability in mind. With an easy enough one-time authentication, you are good to go with this cute little Twitter app. For those interested, go and check out its full documentation. Any bug report or feature request is welcome.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Nhat Minh is a web developer and back-end server engineer who loves digging, creating and building fun stuff on FOSS philosophy. When not being in nerd mode, he can be discovered as a photographer or a go-player in average 1-dan amateur.

Latest posts by Minh Nhat (see all)

One thought on “How to use Twitter in a Linux terminal with Rainbow Stream

Leave a comment

Your email address will not be published. Required fields are marked *