How to add bash completion to Fabric

Warning

This entry was written more than 1 year ago. Please read the article keeping in mind its age.

A little script that add bash completion to your Fabric scripts

If you are a Linux system administrator and you don't know about Fabric [1] yet, I'll suggest you to have a look to this Python library which will help you with your daily systems administration tasks and to deploy your applications.

One thing that I was missing with Fabric was bash completion [2] [3], so I wrote this little script that make my life as system administrator easier.

To install it just save the script as /etc/bash_completion.d/fab.

Let's say that in our fabfile.py script we have defined the following tasks:

$ fab --list
Available commands:

    commit
    deploy
    push 
    test

Now source the bash completion script to test it:

$ . /etc/bash_completion.d/fab

and use the [TAB] key to complete the task name:

$ fab [TAB][TAB]
commit deploy push test

 

Danilo


References

[1] Fabric Documentation

[2] http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_1

[3] http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_2