emre / storm

Manage your SSH like a boss.
http://stormssh.readthedocs.org/en/master/
MIT License
3.94k stars 172 forks source link

Feature request: Zsh completion for stormssh #151

Closed gsusrafael closed 6 years ago

gsusrafael commented 7 years ago

Could it be possible to have some completion for Stormssh in ZSH?

SteveClement commented 7 years ago

Here is a bash completion repo, for your reference

https://github.com/vigo/stormssh-completion

hxsf commented 7 years ago

add this code to you .zshrc

h=()
# add you storm config
if [[ -r ~/.ssh/config ]]; then
  h=($h ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*})
fi
# add you known host
if [[ -r ~/.ssh/known_hosts ]]; then
  h=($h ${${${(f)"$(cat ~/.ssh/known_hosts{,2} || true)"}%%\ *}%%,*}) 2>/dev/null
fi
if [[ $#h -gt 0 ]]; then
  zstyle ':completion:*:ssh:*' hosts $h
  zstyle ':completion:*:slogin:*' hosts $h
fi
emre commented 6 years ago

Thanks @hxsf.

RogerSik commented 5 years ago

For me it seems that the code from @hxsf doens't work.

storm search Test
zsh: correct 'storm' to 'atrm' [nyae]? n
zsh: command not found: storm