SoCLI – Easy way to search or browse stack overflow from the terminal

Stack Overflow is the largest, most trusted online community for developers to learn, share​ ​their programming ​knowledge, and to build their careers. It’s world’s largest developer community and allows users to ask and answer the questions. It’s open alternative to earlier question and answer sites such as Experts-Exchange.

It’s my preferred website, I have learned many programming tricks and many Linux related stuffs as well. Even I asked many questions and answered few questions too when I get time.

Today I have stumbled upon good CLI utility called SoCLI & how2 both are used to browse stackoverflow website from the terminal easily and it’s very helpful when you doesn’t have GUI. Today we are going to discuss about SoCLI and will discuss about how2 in upcoming article.

Suggested Read :
(#) How To Search The Arch Wiki Website Right From Terminal
(#) Googler – Google Search from the command line on Linux
(#) Buku – A Powerful Command-line Bookmark Manager for Linux

This might be very useful for NIX guys, whoever spending most of the time in CLI.

SoCLI is a Stack overflow command line interface written in python. It allows you to search and browse stack overflow from the terminal.

SoCLI Featues:

  • Verity of search is available like Quick Search, Manual Search & interactive Search
  • Coloured interface
  • Question stats view
  • Topic Based Search using tag
  • Can view user profiles
  • Can create a new question via the web browser
  • Can open the page in a browser

How to install Python

Make sure your system should have python-pip package in order to install SoCLI. pip is a python module bundled with setuptools, it’s one of the recommended tool for installing Python packages in Linux.

For Debian/Ubuntu, use apt-get command or apt command to install pip.

$ sudo apt install python-pip

For RHEL/CentOS, use YUM command to install pip.

$ sudo yum install python-pip python-devel

For Fedora, use dnf command to install pip.

$ sudo dnf install python-pip

For Arch Linux, use pacman command to install pip.

$ sudo pacman -S python-pip

For openSUSE, use Zypper Command to install pip.

$ sudo pacman -S python-pip

How to install SoCLI

Simply use pip command to install socli.

$ sudo pip install socli

How to update SoCLI

Run the following command to update your existing version of socli to the newer version to avail latest features.

$ sudo pip install --upgrade socli

How to use SoCLI

Simply fire the socli command on terminal to start explorer stackoverflow from the Linux command line. It offers various arguments which will speedup your search even more faster.

Common syntax for SoCLI

socli [Arguments] [Search Query]

Quick Search

The following command will search for the given query command to check apache active connections and displays the first most voted question in Stack Overflow with its most voted answer.

$ socli command to check apache active connections

Interactive Search

To enable interactive search, use -iq arguments followed by your search query.

The following command will search for the given query delete matching string and print a list of questions from Stack Overflow.

$ socli -iq delete matching string

It will allows users to choose any of the questions interactively by hitting questing number in end of the results. In my case I have choose a question  then it will display the complete description of the chosen question with its most voted answer.

Use UP and DOWN arrow keys to navigate to other answers. Press LEFT arrow key to go back to the list of questions.

Manual Search

SoCLI allows you to display mentioned question number for given query. The following command will search for the given query netstat command examples in Stack Overflow and displays the second question full information for given query alike quick search.

$ socli -r 2 -q netstat command examples

Topic based search

SoCLI allows topic based search by using specific tags. Just mention the specific tags using -t arguments and followed by search query command to increase jvm heap memory.

$ socli -t linux -q command to increase jvm heap memory

For multiple tags, Just separate them with a comma.

$ socli -t linux,unix -q grep

Post a new question

If you can’t find an answer for your question in Stack Overflow? don’t worry, post a new question by running the following command.

$ socli -n

It will open the new question page of Stack Overflow in the web browser for you to create a new question.

Man Page

To know more options & arguments about SoCLI, navigate to help section.

$ socli -h

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

Leave a Reply

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