Search And Browse Stack Overflow Website From Commandline
Stack Overflow is one of the well-known and prominent online community website for Programmers to learn and share their knowledge with millions of users around the world. Also, It is my preferred website when it comes to search, discover programming related stuffs, and questions. If you are anything like me, I have good news for you. Now, you can search and browse Stack Overflow website without leaving your Terminal. Say hello to “SoCLI” , a command line tool to search and browse Stack Overflow site from your Terminal. It will be quite useful when you want to browse Stack Overflow website from a System that has no GUI mode. Using SoCLI, you can post to Stack overflow, upvote and comment an answer. SoCLI is a cross-platform utility, so It will work on GNU/Linux, Microsoft Windows, and Mac OS X.
Concerning about the features of CLI, we can list the following:
- Search and browse Stack Overflow interactively
- Search a specific most voted question with its answer manually
- Search using specific question with single or multiple tags
- Open a page in the default web browser
- Creating new questions via the web browser
- Coloured interface
- Question stats view
In this brief tutorial, we are going to learn to browse Stack Overflow using SoCLI tool from terminal in Linux.
SoCLI – Search and browse Stack Overflow Website From Commandline
SoCLI is a Stack Overflow commandline client written in Python programming language. In order to install it, you need to install python and pip package manager. Pip is the package manager to install applications written using Python.
First, let us install pip.
On Arch Linux and its derivatives:
$ 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
$ sudo dnf install python-pip
$ sudo zypper install python-pip
For more details about pip installation and usage, refer the following link.
Once pip installed, run the following command to install SoCLI. The following command is same for all Linux distributions.
$ sudo pip install socli
To update/upgrade existing socli version, run:
$ sudo pip install --upgrade socli
SoCLI usage is fairly simple and straight forward. The typical syntax of SoCLI is:
$ socli [ Arguments] < Search Query >
Let us see some examples.
To search a query “nginx reverse proxy”, the command would be:
$ socli nginx reverse proxy
This command search the given query “nginx reverse proxy” through Stack Overflow and display the first most voted question with its most voted answer. Cool, isn’t it?
I want to do interactive search, how can do it? That’s very simple. Use “-iq” parameter before your search term (Of course, without quotes).
$ socli -iq ajax in framework7
This command will search the questions for the query “ajax in framework7” and also allow you to choose any one of the question interactively.
Just enter the question number to select a question in the given result. I chose the 6th answer by entering 6 in “Type the option no to continue or any other key to exit” prompt. And it displayed the chosen question with its most voted answer instantly.
Likewise, You can type “n” for the next answer, “b” for previous answer or hit any other key to exit from SoCLI.
Specify a particular Question by number
SoCLI also allows us to display a specific question by its number. Say for example, I want to display the second question of the given query. So, I simply did that by running the following command:
$ socli -r 2 -q cmake
This command will display the second most voted question that has the query “cmake” with its most voted answer.
Topic based search using tags
Stack Overflow allows us to search a particular topic using tags. So, we can do the same using SoCLI client.
Say for example, to search for a query “python” using tag “linux”, run the following command:
$ socli -t linux -q python
You can also include multiple tags using comma as shown below.
$ socli -t linux,android -q python
Submit a new question
Can’t find an answer to your question in Stack Overflow? No worries! Run the following command to create a new question.
$ socli -n
This command will open a new question page of Stack Overflow in your web browser. Please note that you must have installed a web browser to use this feature.
To know more details about SoCLI, refer the help section by running the following ocmmand:
$ socli -h
You know now how to search and browse through questions and answers in Stack Overflow community website via commandline. SoCLI just worked fine as it is advertised in its GitHub page. If you’re a programmer and looking for a client tool for browsing Stack Overflow, you need to give SoCLI a try.
Have you tried this already? Great! Let us know about your experience with SoCLI in the comment section below.
That’s all for now. I will be back soon with another interesting article. If you find this guide useful, please share it on your social, professional networks and support OSTechNix.
More good stuffs to come. Stay tuned!
Thanks for stopping by!
How can I benefit from this blog:
- Subscribe to our Email Newsletter : Sign Up Now
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!