mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
feat(completions/ssh): add support for ssh completion using files in .ssh/config.d too
This commit is contained in:
@@ -5,6 +5,7 @@ _omb_module_require lib:omb-completion
|
|||||||
|
|
||||||
function _omb_completion_ssh {
|
function _omb_completion_ssh {
|
||||||
local cur
|
local cur
|
||||||
|
local file_in_config_d
|
||||||
_omb_completion_reassemble_breaks :
|
_omb_completion_reassemble_breaks :
|
||||||
|
|
||||||
if [[ $cur == *@* ]] ; then
|
if [[ $cur == *@* ]] ; then
|
||||||
@@ -18,6 +19,13 @@ function _omb_completion_ssh {
|
|||||||
COMPREPLY=($(compgen -W "$(grep ^Host "$HOME/.ssh/config" | awk '{for (i=2; i<=NF; i++) print $i}' )" "${options[@]}"))
|
COMPREPLY=($(compgen -W "$(grep ^Host "$HOME/.ssh/config" | awk '{for (i=2; i<=NF; i++) print $i}' )" "${options[@]}"))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# parse all defined hosts from .ssh/config.d/*
|
||||||
|
if [[ -d $HOME/.ssh/config.d ]]; then
|
||||||
|
for file_in_config_d in "$HOME/.ssh/config.d/"* ;do
|
||||||
|
[[ -s "$file_in_config_d" ]] &&COMPREPLY+=($(compgen -W "$(grep ^Host "$file_in_config_d" | awk '{for (i=2; i<=NF; i++) print $i}' )" "${options[@]}"))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# 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
|
||||||
if grep -v -q -e '^ ssh-rsa' "$HOME/.ssh/known_hosts" ; then
|
if grep -v -q -e '^ ssh-rsa' "$HOME/.ssh/known_hosts" ; then
|
||||||
|
Reference in New Issue
Block a user