public
Description: My dotfiles and useful scripts
Homepage:
Clone URL: git://github.com/ricobl/dotfiles.git
Enrico (author)
Fri Nov 20 04:41:18 -0800 2009
commit  c3d83f815f1ee07be2b8948713a13fac5ef16a3f
tree    8e5233b096754f20809e31dbf91acf38b8a0dac3
parent  54d97bf80490be4bafde3a9f5a96555de10eb1c0
dotfiles / bin / fab_bash_completion
100755 37 lines (31 sloc) 0.986 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
 
#
# Name: fab_bash_completion
# Description: Adds tab-completion to fabfile tasks
# Date: 2009-10-28
#
# Author: Enrico Batista da Luz
# E-mail: rico.bl@gmail.com
# Website: http://ricobl.wordpress.com/
#
# Installation: point to this file from your .bash_profile, like so:
#
# . ~/path/to/fab_bash_completion
#
# Mostly adapted from:
#
# http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_2
#
 
_fab_completion()
{
local cur prev opts
 
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
 
# Get the list of available tasks, ignoring errors (missing or invalid fabfile)
# Removing the "Available commands" header and any empty line or spaces
opts="`fab --list 2> /dev/null | grep -v -e 'Available commands' -e "^$" | sed -e 's/ \+\(\w\+\).*/\1/g'`"
 
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _fab_completion -o default fab