Python Invoke is very handy task execution tool, I use it for most of my projects. Before that I had been using a Makefile but I like that now I can use python, but still call out to a shell if I need. To create a very simple example create a file at the base of your project:

from invoke import task

def date(ctx):'date')

Now install the Invoke package with pip install invoke and you should be able to run your example command:

$ invoke date
Sun  3 Jun 2018 13:52:22 BST

A more complex example taken from the Invoke website itself looks like this:

from invoke import task

def clean(c, docs=False, bytecode=False, extra=''):
    patterns = ['build']
    if docs:
    if bytecode:
    if extra:
    for pattern in patterns:"rm -rf {}".format(pattern))

def build(c, docs=False):"python build")
    if docs:"sphinx-build docs docs/_build")

From the command line you can get a list of possible commands with:

$ invoke --list
Available tasks:


And you can get help on a specific command like this:

$ invoke clean -h
Usage: inv[oke] [--core-opts] clean [--options] [other tasks here ...]


  -b, --bytecode
  -d, --docs
  -e STRING, --extra=STRING

This can be quite cumbersome when you half know what your doing but can’t quite remember the name of the command or option you need. For this instance we can enable tab completion. You can read about invoke tab completion in the Invoke Documentation. I use zsh with Oh My Zsh so downloaded the the completion script to ~/.oh-my-zsh/invoke

mkdir ~/.oh-my-zsh/invoke
wget -O ~/.oh-my-zsh/invoke/zsh

and sourced the file in my ~/.zshrc:

echo "\nsource ~/.oh-my-zsh/invoke/zsh" >> ~/.zshrc
source ~/.zshrc

And now we have tab completion of commands with invoke <TAB> and a commands options with invoke <command> -<TAB>.

Note, if you in a virtual environment, you might need to reactive it.