Merge pull request #693 from tomashavlas/ssh-multihost
Added support for multiple aliases/hostnames in single line for ssh completion and pluginpull/694/head
commit
f3f4f0a8f9
|
|
@ -14,7 +14,7 @@ _sshcomplete() {
|
||||||
|
|
||||||
# parse all defined hosts from .ssh/config
|
# parse all defined hosts from .ssh/config
|
||||||
if [ -r "$HOME/.ssh/config" ]; then
|
if [ -r "$HOME/.ssh/config" ]; then
|
||||||
COMPREPLY=($(compgen -W "$(grep ^Host "$HOME/.ssh/config" | awk '{print $2}' )" ${OPTIONS}) )
|
COMPREPLY=($(compgen -W "$(grep ^Host "$HOME/.ssh/config" | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# parse all hosts found in .ssh/known_hosts
|
# parse all hosts found in .ssh/known_hosts
|
||||||
|
|
@ -26,7 +26,7 @@ _sshcomplete() {
|
||||||
|
|
||||||
# parse hosts defined in /etc/hosts
|
# parse hosts defined in /etc/hosts
|
||||||
if [ -r /etc/hosts ]; then
|
if [ -r /etc/hosts ]; then
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{print $2}' )" ${OPTIONS}) )
|
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,5 @@ function sshlist() {
|
||||||
about 'list hosts defined in ssh config'
|
about 'list hosts defined in ssh config'
|
||||||
group 'ssh'
|
group 'ssh'
|
||||||
|
|
||||||
awk '$1 ~ /Host$/ { print $2 }' ~/.ssh/config
|
awk '$1 ~ /Host$/ {for (i=2; i<=NF; i++) print $i}' ~/.ssh/config
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue