In our series of Linux Lexicon, we are continuously adding new articles to help you learn Linux from the scratch. In our articles covering the basic Linux commands, you would have come across the one telling you about man pages and their navigation. Each Linux command line program has its own documentation that’s listed in its man pages.
Man pages of Linux are limited to the operating system and you can access them anytime in your terminal. But, what to do if you want to get some specific answer related to some programming language or anything else? You’ll be opening your web browser and typing in the query to get the answer.
Well, if you are a terminal animal, then there’s a way to access StackOverflow right from the terminal itself. In this article, I’ll be telling you how to do that and make your terminal session more interesting.
Using a simple script, surfing StackOverflow in Terminal becomes an easy task. If you spend a lot of productive time in the terminal, you need to install how2 on Ubuntu-based distros to achieve this functionality.
To install the how2 command, you need to execute following steps:
$ sudo apt-get update $ sudo apt-get dist-upgrade
$ sudo apt-get install nodejs
$ sudo npm install -g how2
Note: It’s possible that your Linux distribution makes use of nodejs instead of node. So, you need to make a symlink in order to make things work:
ln -s /usr/bin/nodejs /usr/bin/node
For installing How2 tool on your macOS terminal, you need to install node with brew using the following command:
brew install node.
Install How2 using the same Linux command as mentioned above.
Now, to use the tool, you can search StackOverflow by using how2 command followed by the desired query:
how2 implement if in shell script
You’ll be getting the output screen on Mac something like this:
To get more options, you can press spacebar to launch the interactive mode to get a list of StackOverflow question/answers.
To get more information about this tool and its usage, you can head over to How2’s GitHub page.
Did you find this article interesting? Don’t forget to drop your feedback in the comments section below.