Browse Source

Fixed zsh completion.

Kenny Woodson 10 years ago
parent
commit
912ba64e80
1 changed files with 10 additions and 6 deletions
  1. 10 6
      bin/_ossh_zsh_completion

+ 10 - 6
bin/_ossh_zsh_completion

@@ -2,7 +2,7 @@
 
 _ossh_known_hosts(){
   if [[ -f ~/.ansible/tmp/multi_ec2_inventory.cache ]]; then
-    /usr/bin/python -c 'import json,os; z = json.loads(open("%s"%os.path.expanduser("~/.ansible/tmp/multi_ec2_inventory.cache")).read()); print "\n".join(["%s.%s" % (host["ec2_tag_Name"],host["ec2_tag_environment"]) for dns, host in z["_meta"]["hostvars"].items()])'
+    print $(/usr/bin/python -c 'import json,os; z = json.loads(open("%s"%os.path.expanduser("~/.ansible/tmp/multi_ec2_inventory.cache")).read()); print "\n".join(["%s.%s" % (host["ec2_tag_Name"],host["ec2_tag_environment"]) for dns, host in z["_meta"]["hostvars"].items()])')
   fi
 
 }
@@ -10,11 +10,15 @@ _ossh(){
   local curcontext="$curcontext" state line
   typeset -A opt_args
 
-  _arguments -s : \
-      "*:Hosts:_ossh_known_hosts"
+#_arguments "*:Hosts:_ossh_known_hosts"
+    _arguments -s : \
+        "*:hosts:->hosts"
+
+    case "$state" in
+        hosts)
+            _values 'hosts' $(_ossh_known_hosts)
+            ;;
+    esac
 
-  case $state in
-  *)
-        
 }
 _ossh "$@"