Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completions/ssh: Include global ssh hosts #569

Merged
merged 5 commits into from
May 29, 2024

Conversation

plasmastorm
Copy link
Contributor

Partial fix for #568

Copy link
Contributor

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. I merged another PR of ssh_config #529. The suggested addition of the support for /etc/ssh/ssh_{config,known_hosts} is good. However, I'd like to reduce the code duplicates before merging.

Could you rebase on top of the latest master and modify the code to store the found files in an array and run e.g. awk /^HOST/ ... "${config_files[@]}" at once?

local -a config_files=()
if [[ -r ~/.ssh/config ]]; then
  config_files+=(~/.ssh/config)
  ...
fi
if [[ -r /etc/ssh/ssh_config ]]; then
  config_files+=(/etc/ssh/ssh_config)
fi
COMPREPLY+=($(compgen -W "$(awk '/^Host/ {for (i=2; i<=NF; i++) print $i}' "${config_files[@]}")" "${options[@]}"))

Similar for known_hosts.

@plasmastorm
Copy link
Contributor Author

plasmastorm commented May 9, 2024

Will do - /etc/ssh/ssh_config can also Include files, worth trying to work it in with the new changes by looping over both config files?

@akinomyoga
Copy link
Contributor

Ah, right. I think the Include there can also be processed.

@plasmastorm plasmastorm force-pushed the ssh-global-completion branch from 1645fc3 to 3520883 Compare May 10, 2024 17:38
completions/ssh.completion.sh Show resolved Hide resolved
completions/ssh.completion.sh Outdated Show resolved Hide resolved
completions/ssh.completion.sh Outdated Show resolved Hide resolved
completions/ssh.completion.sh Outdated Show resolved Hide resolved
@akinomyoga akinomyoga force-pushed the ssh-global-completion branch from 649799f to e155f9a Compare May 29, 2024 01:53
@akinomyoga akinomyoga merged commit 52a8fad into ohmybash:master May 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants