diff options
Diffstat (limited to 'plugins/knife_ssh')
-rw-r--r-- | plugins/knife_ssh/README.md | 14 | ||||
-rw-r--r-- | plugins/knife_ssh/knife_ssh.plugin.zsh | 8 |
2 files changed, 18 insertions, 4 deletions
diff --git a/plugins/knife_ssh/README.md b/plugins/knife_ssh/README.md new file mode 100644 index 000000000..cb836b7f3 --- /dev/null +++ b/plugins/knife_ssh/README.md @@ -0,0 +1,14 @@ +# knife_ssh plugin + +This plugin adds a `knife_ssh` function as well as completion for it, to allow +connecting via ssh to servers managed with [Chef](https://www.chef.io/). + +To use it, add `knife_ssh` to the plugins array in your zshrc file: +```zsh +plugins=(... knife_ssh) +``` + +The plugin creates a cache of the Chef node list via `knife`, and stores it +in `$HOME/.knife_comp~`, when first triggering knife_ssh completion. + +**Requirements:** `knife` has to be installed. diff --git a/plugins/knife_ssh/knife_ssh.plugin.zsh b/plugins/knife_ssh/knife_ssh.plugin.zsh index 7fdd42a1e..dc425a33e 100644 --- a/plugins/knife_ssh/knife_ssh.plugin.zsh +++ b/plugins/knife_ssh/knife_ssh.plugin.zsh @@ -1,17 +1,17 @@ function knife_ssh() { - grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~; + 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 + echo "\nGenerating ~/.knife_comp~..." >&2 knife node list > ~/.knife_comp~ fi - compadd $(<~/.knife_comp~) + compadd $(< ~/.knife_comp~) else - echo "Could not find knife" > /dev/stderr; + echo "Could not find knife" >&2 fi } |