summaryrefslogtreecommitdiffstats
path: root/bin/ossh_bash_completion
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-02-05 17:06:56 -0500
committerKenny Woodson <kwoodson@redhat.com>2015-02-05 17:06:56 -0500
commitaafbcce3605b7f992ba4b73d67286dbb40461baa (patch)
treec902148de7e314a51771d94df1331b9fb28e1d99 /bin/ossh_bash_completion
parent04343e7588118359d178fa63554909efb222648a (diff)
parent04582ead281239524df87f1dabc53125038ff9a5 (diff)
downloadopenshift-aafbcce3605b7f992ba4b73d67286dbb40461baa.tar.gz
openshift-aafbcce3605b7f992ba4b73d67286dbb40461baa.tar.bz2
openshift-aafbcce3605b7f992ba4b73d67286dbb40461baa.tar.xz
openshift-aafbcce3605b7f992ba4b73d67286dbb40461baa.zip
Merge pull request #54 from kwoodson/ossh
Adding ssh dynamic hosts capabilities
Diffstat (limited to 'bin/ossh_bash_completion')
-rwxr-xr-xbin/ossh_bash_completion18
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/ossh_bash_completion b/bin/ossh_bash_completion
new file mode 100755
index 000000000..0d0bdb0e6
--- /dev/null
+++ b/bin/ossh_bash_completion
@@ -0,0 +1,18 @@
+__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()])'
+ fi
+}
+
+_ossh()
+{
+ local cur prev known_hosts
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ known_hosts="$(__ossh_known_hosts)"
+ COMPREPLY=( $(compgen -W "${known_hosts}" -- ${cur}))
+
+ return 0
+}
+complete -F _ossh ossh