knife_ssh.plugin.zsh 457 B

123456789101112131415161718
  1. function knife_ssh() {
  2. grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~;
  3. ssh $(knife node show $1 | awk '/IP:/{print $2}')
  4. }
  5. _knife_ssh() {
  6. if hash knife 2>/dev/null; then
  7. if [[ ! -f ~/.knife_comp~ ]]; then
  8. echo "\nGenerating ~/.knife_comp~..." >/dev/stderr
  9. knife node list > ~/.knife_comp~
  10. fi
  11. compadd $(<~/.knife_comp~)
  12. else
  13. echo "Could not find knife" > /dev/stderr;
  14. fi
  15. }
  16. compdef _knife_ssh knife_ssh