2aebcb80bb39568d75e30cf19cb99a57ebac1181
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #1981 from trobrock/knife-ssh
Add knife_ssh command to make connecting to servers managed with chef easier
Diff
1diff --git a/plugins/knife_ssh/knife_ssh.plugin.zsh b/plugins/knife_ssh/knife_ssh.plugin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..7fdd42a1ebb30d2a403aef42081ddae2b6db205d
4--- /dev/null
5+++ b/plugins/knife_ssh/knife_ssh.plugin.zsh
6@@ -0,0 +1,18 @@
7+function knife_ssh() {
8+ grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~;
9+ ssh $(knife node show $1 | awk '/IP:/{print $2}')
10+}
11+
12+_knife_ssh() {
13+ if hash knife 2>/dev/null; then
14+ if [[ ! -f ~/.knife_comp~ ]]; then
15+ echo "\nGenerating ~/.knife_comp~..." >/dev/stderr
16+ knife node list > ~/.knife_comp~
17+ fi
18+ compadd $(<~/.knife_comp~)
19+ else
20+ echo "Could not find knife" > /dev/stderr;
21+ fi
22+}
23+
24+compdef _knife_ssh knife_ssh