Fix wildcards and handle includes in ssh complete
Handle includes in `.ssh/config` and fix bug that caused `Host` entries with wildcards in them to be included in the autocomplete suggestions.pull/1205/head
parent
7c09252ac8
commit
0936e2a029
|
|
@ -11,11 +11,16 @@ _sshcomplete() {
|
||||||
local OPTIONS=" -- ${CURRENT_PROMPT}"
|
local OPTIONS=" -- ${CURRENT_PROMPT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# parse all defined hosts from .ssh/config and files included there
|
||||||
# parse all defined hosts from .ssh/config
|
for fl in "$HOME/.ssh/config" \
|
||||||
if [ -r "$HOME/.ssh/config" ]; then
|
$(grep -P "^\s*Include" "$HOME/.ssh/config" |
|
||||||
COMPREPLY=($(compgen -W "$(grep -i ^Host "$HOME/.ssh/config" | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) )
|
awk '{for (i=2; i<=NF; i++) print $i}' |
|
||||||
|
sed "s|^~/|$HOME/|")
|
||||||
|
do
|
||||||
|
if [ -r "$fl" ]; then
|
||||||
|
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$(grep -i ^Host "$fl" |grep -v '[*!]' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) )
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# parse all hosts found in .ssh/known_hosts
|
# parse all hosts found in .ssh/known_hosts
|
||||||
if [ -r "$HOME/.ssh/known_hosts" ]; then
|
if [ -r "$HOME/.ssh/known_hosts" ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue