DEV Community

Cover image for Visit StackOverflow without leaving the terminal with Python
Stokry
Stokry

Posted on

Visit StackOverflow without leaving the terminal with Python

Stuck on a coding problem? Wish to visit StackOverflow without leaving the terminal? With howdoi, you can do it!

Introduction to howdoi

Howdoi is an open source command line tool that gives answers to your questions right on the command line. Howdoi can be used by anyone and everyone who finds themselves Googling for answers to their basic programming questions.

You wonder:

howdoi print hello in python
Enter fullscreen mode Exit fullscreen mode

Howdoi output:

print(hello)
Enter fullscreen mode Exit fullscreen mode

Installation

pip install howdoi
Enter fullscreen mode Exit fullscreen mode

Suppose you want to know how to format a date in bash. Why open your browser and read through blogs (risking major distraction) when you can simply stay in the console and ask howdoi:

$ howdoi format date bash
> DATE=`date +%Y-%m-%d`
Enter fullscreen mode Exit fullscreen mode

howdoi will answer all sorts of queries:

$ howdoi print stack trace python
> import traceback
>
> try:
>     1/0
> except:
>     print '>>> traceback <<<'
>     traceback.print_exc()
>     print '>>> end of traceback <<<'
> traceback.print_exc()

$ howdoi convert mp4 to animated gif
> video=/path/to/video.avi
> outdir=/path/to/output.gif
> mplayer "$video" \
>         -ao null \
>         -ss "00:01:00" \  # starting point
>         -endpos 10 \ # duration in second
>         -vo gif89a:fps=13:output=$outdir \
>         -vf scale=240:180

$ howdoi create tar archive
> tar -cf backup.tar --exclude "www/subf3" www
Enter fullscreen mode Exit fullscreen mode

You can also search other StackExchange properties for answers:

HOWDOI_URL=cooking.stackexchange.com howdoi make pesto
Enter fullscreen mode Exit fullscreen mode

or as an alias:

alias hcook='function hcook(){ HOWDOI_URL=cooking.stackexchange.com howdoi $* ; }; hcook'
hcook make pesto
Enter fullscreen mode Exit fullscreen mode

I advise you to visit this link: howdoi

There is also an Visual Studio Code Extension, Head over to the MarketPlace to install the extension.

Thank you all.

Top comments (3)

Collapse
 
gabrielweidmann profile image
Gabriel Weidmann

Interesting idea, but I'm still a lot faster just entering my question in the webbrowser and searching the web directly.

You should make it an extension for a pc search app like Wox

Collapse
 
lioness100 profile image
Lioness100

Super cool!

Collapse
 
domonic profile image
domonic

very cool.