diff options
Diffstat (limited to 'bash/bash_completion.d/ssh.bash')
-rw-r--r-- | bash/bash_completion.d/ssh.bash | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/bash/bash_completion.d/ssh.bash b/bash/bash_completion.d/ssh.bash index bbb9b246..03745eaa 100644 --- a/bash/bash_completion.d/ssh.bash +++ b/bash/bash_completion.d/ssh.bash @@ -1,22 +1,4 @@ -# Completion for ssh/sftp/ssh-copy-id with config hostnames -_ssh() { - - # 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 - [[ -e $config ]] || continue - while read -r option value _ ; do - [[ $option == Host ]] || continue - [[ $value != *'*'* ]] || continue - hosts[${#hosts[@]}]=$value - done < "$config" - done - - # Generate completion reply - for host in "${hosts[@]}" ; do - [[ $host == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue - COMPREPLY[${#COMPREPLY[@]}]=$host - done -} -complete -F _ssh -o default ssh sftp ssh-copy-id +# Completion for ssh(1) with ssh_config(5) hostnames +declare -F _ssh_config_hosts >/dev/null || + source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash +complete -F _ssh_config_hosts -o default ssh |