summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2013-07-16 20:43:45 -0700
committerRobby Russell <robby@planetargon.com>2013-07-16 20:43:45 -0700
commit2aebcb80bb39568d75e30cf19cb99a57ebac1181 (patch)
tree8c2a61e08be5de3be8b004c0cae1e496d5edd3cb
parent7f74294d7aa7ab86e18e70a1153c15fa373c5849 (diff)
parent9a9e6e929964cbb25c5ce656a995e31ab9636762 (diff)
downloadzsh-2aebcb80bb39568d75e30cf19cb99a57ebac1181.tar.gz
zsh-2aebcb80bb39568d75e30cf19cb99a57ebac1181.tar.bz2
zsh-2aebcb80bb39568d75e30cf19cb99a57ebac1181.zip
Merge pull request #1981 from trobrock/knife-ssh
Add knife_ssh command to make connecting to servers managed with chef easier
-rw-r--r--plugins/knife_ssh/knife_ssh.plugin.zsh18
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/knife_ssh/knife_ssh.plugin.zsh b/plugins/knife_ssh/knife_ssh.plugin.zsh
new file mode 100644
index 000000000..7fdd42a1e
--- /dev/null
+++ b/plugins/knife_ssh/knife_ssh.plugin.zsh
@@ -0,0 +1,18 @@
+function knife_ssh() {
+ grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~;
+ ssh $(knife node show $1 | awk '/IP:/{print $2}')
+}
+
+_knife_ssh() {
+ if hash knife 2>/dev/null; then
+ if [[ ! -f ~/.knife_comp~ ]]; then
+ echo "\nGenerating ~/.knife_comp~..." >/dev/stderr
+ knife node list > ~/.knife_comp~
+ fi
+ compadd $(<~/.knife_comp~)
+ else
+ echo "Could not find knife" > /dev/stderr;
+ fi
+}
+
+compdef _knife_ssh knife_ssh