How To Get Instant Coding Answers Via Commandline In Linux
Are you a programmer? I’ve got a good news for you. You can now get instant coding answers via commandline using ‘howdoi’ utility in Unix-like operating systems. You don’t have to google or refer any other online resources to know about some basic programming queries. Howdoi will display the instant answers for codes and command queries right from your Terminal. This tool could be useful where you don’t have to access the web browser. It should work on any operating systems that supports python 2 and python 3, including GNU/Linux and Windows operating systems.
This brief tutorial describes how to install and use howdoi utility in Linux.
Get Instant Coding Answers Via Commandline using ‘Howdoi’
Howdoi can be easily installed using pip utility. To install pip in your Linux distribution, do the following steps.
To install PIP on Arch Linux and its derivatives, run:
$ sudo pacman -S python-pip
On RHEL, Fedora, CentOS:
$ sudo yum install epel-release
$ sudo yum install python-pip
$ sudo dnf install epel-release
$ sudo dnf install python-pip
On Debian, Ubuntu, Linux Mint:
$ sudo apt-get install python-pip
Once PIP installed, run the following command to install ‘Howdoi’.
$ sudo pip install howdoi
The typical syntax of Howdoi is:
howdoi [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] [-C] [-v] QUERY [QUERY ...]
- -h – Displays the help section
- -p POS – Select answer in specified position (default: 1)
- -a – Displays the full text of the answer
- -l – Displays only the answer link
- -c – Enables colorized output
- -n NUM_ANSWERS – Number of answers to return
- -C – Clears the cache
- -v – Displays the current version of howdoi
Let us see some examples.
To know how to use print function in python or java, use following commands:
$ howdoi print python
print("Total score for %s is %s " % (name, score))
$ howdoi print java
To know how to create an archive, just run the following command:
$ howdoi create tar archive
Sample output would be:
$ tar czf file.tar.gz file.txt
You could use this command to create a tar archive of file.txt. Similarly, you can search any commands. Here is how to know the command format to create a file or directory.
$ howdoi create file touch
Similarly, you can view how to create a directory as shown below.
$ howdoi create directory mkdir
$ mkdir -p foo
To know how to format a date in bash, just run:
$ howdoi format date bash
Please note that this utility may not find answers to all queries, but it will help you to find answers to some basic codes and command queries.
Hope this helps.