From 9c0ceb7a5291950551d95d9314573c26c73e6b0e Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 27 Dec 2019 00:56:03 +0100 Subject: knife_ssh: add README --- plugins/knife_ssh/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 plugins/knife_ssh/README.md (limited to 'plugins/knife_ssh') 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. -- cgit v1.2.3-70-g09d2 From e891fbff9e2e70acfbeff0734cd1fc012861e6ef Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 27 Dec 2019 00:58:31 +0100 Subject: knife_ssh: small tweaks --- plugins/knife_ssh/knife_ssh.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/knife_ssh') 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 } -- cgit v1.2.3-70-g09d2