Skip to main content

Instant coding answers via the command line

Project description

This is a fork of Benjamin Gleitzman’s excellent Howdoi tool.

It’s been extended to support a local indexed cache of answers using Elasticsearch as the backend search server. This allows faster searches and the ability to add custom answer annotations and documentation via a local YAML file.

I made this modification when I realized that howdoi is ideal for finding common one-liners when what I really needed was help finding less common guides and solutions for subtle, but more complex problems. In these cases, I found that the solutions provided by howdoi still required I do more research and write notes, notes that I needed to store somewhere for later reference.

My solution was to organized my notes in a YAML file, index this file with Elasticsearch, and modify howdoi to refer to my Elasticsearch index first.

Instant coding answers via the command line

Are you a hack programmer? Do you find yourself constantly Googling for how to do basic programing tasks?

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 howdou:

$ howdou format date bash
> DATE=`date +%Y-%m-%d`

howdou will answer all sorts of queries:

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

$ howdou 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

$ howdou create tar archive
> tar -cf backup.tar --exclude "www/subf3" www


First, install Elasticsearch. On Ubuntu, this is simply:

sudo apt-get install elasticsearch

Then install howdou via pip with:

pip install howdou


pip install git+


python install


The command line is pretty straight-forward:

usage: [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] QUERY [QUERY ...]

instant coding answers via the command line

positional arguments:
  QUERY                 the question to answer

optional arguments:
  -h, --help            show this help message and exit
  -p POS, --pos POS     select answer in specified position (default: 1)
  -a, --all             display the full text of the answer
  -l, --link            display only the answer link
  -c, --color           enable colorized output
  -n NUM_ANSWERS, --num-answers NUM_ANSWERS
                        number of answers to return
  -C, --clear-cache     clear the cache

To take full advantage of howdou, you’ll need to maintain a local howdou.yml file, which is a simple serialized list of QA-sets that look like:

-   questions:
    -   format date bash
    -   weight: 1
        date: 2014-5-14
        formatter: bash
        text: |-
            DATE=`date +%Y-%m-%d`

Note each item is an association of many-questions to many-answers. This is because there are many ways to ask the same thing, and we want the index to be as likely as possible to correctly match your question to an answer.

There’s also an explicit weight value, which will be incorporated into Elasticsearch’s own search weight to control the order that results are shown.


You can run unittests by downloading and extracting the source tarball and running:

python test

Project details

Release history Release notifications

History Node


History Node


History Node


History Node


History Node


History Node


This version
History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
howdou-2.0.3.tar.gz (8.9 kB) Copy SHA256 hash SHA256 Source None Jul 7, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page