Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Or... just say "zsh"' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Or... just say "zsh"
Authored by: pmccann on Oct 14, '04 08:18:01PM

In yet another "or just..." reply, we have: just switch to a nicer shell. If you use zsh as your shell the host completion stuff is implemented very nicely by default. You just add a list of hosts to your .zshrc file (in the form

hosts=(host1.example.com host2.example.com another.machine.com)

and tab completion of the host applies not just to the ssh command, but to scp, sftp and --as something of a killer feature, especially for users happy with setting up ssh keys-- you also get tab completion of filenames on the remote host when using scp. Beautiful!



[ Reply to This | # ]
Or... just say "zsh"
Authored by: Titanium Man on Oct 14, '04 09:18:11PM
Bits of my .zshrc which pull hosts out of ~/.ssh/known_hosts (I stole this from somewhere and modified it) and enable the tab completion:
autoload -U compinit
compinit -C -d ~/.zcompdump_$ZSH_VERSION
typeset -aU hostnames
hostnames=(
host1.example.com
host2.example.com
host1.otherexample.com
)
[[ -f $HOME/.ssh/known_hosts ]] && hostnames+=(
${${${${(f)"$(
     

[ Reply to This | # ]
Or... just say "zsh"
Authored by: Titanium Man on Oct 14, '04 09:20:46PM

Yikes, that should look like this:

autoload -U compinit
compinit -C -d ~/.zcompdump_$ZSH_VERSION
typeset -aU hostnames
hostnames=(
host1.example.com
host2.example.com
host1.otherexample.com
)
[[ -f $HOME/.ssh/known_hosts ]] && hostnames+=(
${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*}
)
zstyle ':completion:*:*:ssh:*:hosts' hosts $hostnames
zstyle ':completion:*:*:ftp:*:hosts' hosts $hostnames
zstyle ':completion:*:hosts' hosts $hostnames



[ Reply to This | # ]