summaryrefslogtreecommitdiffstats
path: root/bin/ossh_zsh_completion
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-02-05 14:18:09 -0500
committerKenny Woodson <kwoodson@redhat.com>2015-02-05 14:18:09 -0500
commit55b7f22404da7a0cfcdbce467e9581f6b8509320 (patch)
treebac3cb599c1e4fc9790153ddfc7b7b82f29e43e1 /bin/ossh_zsh_completion
parent912ba64e80dc3e086df4e9b65577fe490ff37c70 (diff)
downloadopenshift-55b7f22404da7a0cfcdbce467e9581f6b8509320.tar.gz
openshift-55b7f22404da7a0cfcdbce467e9581f6b8509320.tar.bz2
openshift-55b7f22404da7a0cfcdbce467e9581f6b8509320.tar.xz
openshift-55b7f22404da7a0cfcdbce467e9581f6b8509320.zip
Updated tab completion as well as respecting ssh config files.
Diffstat (limited to 'bin/ossh_zsh_completion')
-rw-r--r--bin/ossh_zsh_completion24
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/ossh_zsh_completion b/bin/ossh_zsh_completion
new file mode 100644
index 000000000..f057ca8ce
--- /dev/null
+++ b/bin/ossh_zsh_completion
@@ -0,0 +1,24 @@
+#compdef ossh
+
+_ossh_known_hosts(){
+ if [[ -f ~/.ansible/tmp/multi_ec2_inventory.cache ]]; then
+ 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
+
+}
+_ossh(){
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+
+#_arguments "*:Hosts:_ossh_known_hosts"
+ _arguments -s : \
+ "*:hosts:->hosts"
+
+ case "$state" in
+ hosts)
+ _values 'hosts' $(_ossh_known_hosts)
+ ;;
+ esac
+
+}
+_ossh "$@"