From 19cea6c4435ec4fbbe7c66de6140f51348fc67bd Mon Sep 17 00:00:00 2001 From: Mark Walling Date: Sat, 4 Jun 2011 16:35:33 -0400 Subject: [PATCH] Added completion support for fabric targets Provides completion for fabric targets from the `fab` command line. --- plugins/fabric/_fab | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/fabric/_fab diff --git a/plugins/fabric/_fab b/plugins/fabric/_fab new file mode 100644 index 000000000..cdc2304a4 --- /dev/null +++ b/plugins/fabric/_fab @@ -0,0 +1,27 @@ +#compdef fab +#autoload + +# I tried doing bash tricks to get the target list parsed, and gave up. + +_fabric_targets() { + local line + fabric_targets=() + fab --list 2>/dev/null | python -c " +import re, sys +fab_target_matcher = re.compile(r'^ (?P[a-z_]+)\s+(?P.*)$') +for line in sys.stdin: + matcher = fab_target_matcher.match(line) + if matcher is not None: + target = matcher.group('target') + description = matcher.group('description').strip() + if len(description) == 0: + description = target + print \"%s:%s\" % (target, description) +" \ + | while read line; do fabric_targets+=($line); done +} + +local -a fabric_targets + +_fabric_targets +_describe -t commands "fab target" fabric_targets