blob: ea3c70a6a0318c54a55ebb46a773c0fddea9b049 (
plain) (
tree)
|
|
# Completion for ssh/sftp/ssh-copy-id with config hostnames
_ssh() {
local word
word=${COMP_WORDS[COMP_CWORD]}
# Read hostnames from existent config files, no asterisks
local -a hosts
local config option value
for config in "$HOME"/.ssh/config /etc/ssh/ssh_config ; do
if [[ -e $config ]] ; then
while read -r option value _ ; do
if [[ $option == Host && $value != *'*'* ]] ; then
hosts=("${hosts[@]}" "$value")
fi
done < "$config"
fi
done
# Generate completion reply
COMPREPLY=( $(compgen -W "${hosts[*]}" -- "$word") )
}
complete -F _ssh -o default ssh sftp ssh-copy-id
|