Some time ago, we wrote about SoCLI, a Python script for searching and browsing Stack Overflow sites from the command line. Today, we’ll talk about a similar tool called “HOW2.” It is a command line program that browses Stack Overflow from a terminal. You can query directly in English as you would in Google Search, and it will use Google and Stackoverflow apis to search for a given query. It is a free open source program written using NodeJS.
Browse Stack Overflow from a terminal using how2
Since HOW2 is a NodeJS package, we can install it using the Npm package manager. If you do not already have Npm and NodeJS installed, please refer to the following guide.
After installing Npm and NodeJS, run the following command to install HOW2.
$ npm install -g how2Copy the code
Now let’s take a look at how to browse Stack Overflow using this program. A typical use of how2 to search Stack Overflow sites is:
$ how2 <search-query>Copy the code
For example, I’ll search for how to create a TGZ archive.
$ how2 create archive tgzCopy the code
Oh dear! I received the following error.
/ home/sk /. NVM/versions/node/v9.11.1 / lib/node_modules/how2 / node_modules/devnull/transports/transport. Js: 59 Transport.prototype.__proto__ = EventEmitter.prototype; ^ TypeError: Cannot read property 'prototype' of undefined at Object.<anonymous> (/ home/sk/NVM/versions/node/v9.11.1 / lib/node_modules/how2 / node_modules/devnull/transports/transport. Js: 59:46) at Module._compile (internal/modules/cjs/loader.js:654:30) at Object.Module._extensions.. js (internal/modules/cjs/loader.js:665:10) at Module.load (internal/modules/cjs/loader.js:566:32) at tryModuleLoad (internal/modules/cjs/loader.js:506:12) at Function.Module._load (internal/modules/cjs/loader.js:498:3) at Module.require (internal/modules/cjs/loader.js:598:17) at require (internal/modules/cjs/helpers.js:11:18) at Object.<anonymous> (/ home/sk/NVM/versions/node/v9.11.1 / lib/node_modules/how2 / node_modules/devnull/transports/stream. Js: 8:17) at Module._compile (internal/modules/cjs/loader.js:654:30)Copy the code
I think I ran into a bug. I hope it gets fixed in a future release. However, I have found a temporary solution here.
To temporarily fix this error, you need to edit transport.js with the following command:
$vi/home/sk /. NVM/versions/node/v9.11.1 / lib/node_modules/how2 / node_modules/devnull/transports/transport. JsCopy the code
The actual path to this file is shown in the error output. Replace the above file paths with your own. Then find the following line:
var EventEmitter = process.EventEmitter;Copy the code
Replace it with the following line:
var EventEmitter = require('events');Copy the code
Press ESC and enter :wq to save and exit the file.
Now search the query again.
$ how2 create archive tgzCopy the code
This is sample output from my Ubuntu system.
If the answer you’re looking for doesn’t show up in the output above, press the space bar to begin an interactive search that allows you to view all the suggested questions and answers on the Stack Overflow site.
Use the up/down arrows to move between results. Once you have the correct answer/question, hit the space bar or Enter key to open it in terminal.
To return and exit, press ESC.
Search for language-specific answers
If you don’t specify a language, it defaults to the Bash Unix command line and immediately gives you the most likely answer. You can also narrow the results to specific languages, such as Perl, Python, C, Java, and so on.
For example, use the -l flag to search only queries related to the “Python” language, as shown below.
$ how2 -l python linked listCopy the code
For quick help, enter:
$ how2 -hCopy the code
conclusion
How2 is a basic command-line program that can quickly search Stack Overflow for questions and answers without leaving the terminal, and it does the job just fine. However, it’s just a CLI browser for Stack Overflow. For advanced features such as searching for the most voted questions, using multiple tag search queries, a color interface, submitting new questions and viewing problem statistics, SoCLI does a better job.
That’s it. Hope this article is useful. I will write a new guide soon. Until then, stay tuned!
Cheers!
via: https://www.ostechnix.com/how-to-browse-stack-overflow-from-terminal/
SK Selected by Lujun9972
This article is originally compiled by LCTT and released in Linux China