chezmoi init

This commit is contained in:
Cy Pokhrel 2024-10-22 11:11:45 -04:00
commit 530d6d7195
No known key found for this signature in database
GPG key ID: 1200FBE36C2ADE2E
1176 changed files with 111325 additions and 0 deletions

View file

@ -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.

View file

@ -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~..." >&2
knife node list > ~/.knife_comp~
fi
compadd $(< ~/.knife_comp~)
else
echo "Could not find knife" >&2
fi
}
compdef _knife_ssh knife_ssh