In this article, I am going to show you how to install Stack Overflow command line interface (SoCLI) on Linux. Stack Overflow is a question and answer website on the topic of computer programming. We can use command line interface to get any information from Linux terminal without using the graphical web interface or terminal browser.
Prerequirements
Due to SoCLI is written on Python we need installed python-pip. SoCLI supports python>2.0 so there should be no problems with installing it on any Linux distributive. If there is no python-pip package in your system you can install it using commands below.
For Ubuntu/Debian:
$ sudo apt-get install python-pip
For RedHat/CentOS:
# yum install python-pip
Verify pip installation:
$ pip –help
or
$ pip -V
Installing
Now we can install SoCLI
# pip install socli
and start using it by executing
$ socli
Search
Basic SoCLI syntax is socli [Arguments] <Query>
Let's make a search with SoCLI example
$ socli for loop in python
Seems it is working good. Let's find something interesting
$ socli nginx balancer
Interactive search
One more feature that can be very helpful is interactive search.
$ socli -iq case in python
This command will look for 'case' in python topics and return top 10 questions.
Now you must enter number from 0 to 9 and select the needed question. Let it be number 3.
One more feature of interactive mode is that you can switch between questions using arrow keys.
Getting question by number
SoCLI allows to get a specific question by its number.
Let it show us the third question of query
$ socli -r 3 -q unix
Tags
Another Stack Overflow CLI feature is searching using tags with -t key. For example:
$ socli -t linux -q iptable
You can combine any tags just separating them with commas.
Creating your own question
Stack Overflow command line interface allows you to create your own questions.
$ socli -n
Executing this command will open a new question page in the browser.
To get any additional help you can type
$ socli -h
For any additional information, you can refer to SoCLI on GitHub
It asks the google, not SO directly. Wrong!
I installed socli and verified it was installed with 'pip list'. But the command 'socli' is not found. I tried again in another terminal. Any ideas? Many of the other entries in 'pip list' are not valid commands (the only exception I found was also installed from the package manager.) I assume this is a path issue. I used 'pip show socli' to find the installation location; from there, socli.py will execute, but it gave an error that another (installed) package was not found. I added their common directory to my PATH, but nothing changed.