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

ssh completion doesn't include global ssh hosts #568

Open
plasmastorm opened this issue May 7, 2024 · 3 comments
Open

ssh completion doesn't include global ssh hosts #568

plasmastorm opened this issue May 7, 2024 · 3 comments

Comments

@plasmastorm
Copy link
Contributor

It would be good if ssh completion could include global hosts from /etc/ssh/ssh_known_hosts and /etc/ssh/ssh_config

Would be good to also support /etc/ssh/ssh_config.d/* in the same way as #529 is about to

@akinomyoga
Copy link
Contributor

Would be good to also support /etc/ssh/ssh_config.d/* in the same way as #529 is about to

Those files are supposed to be included by /etc/ssh/ssh_config, so they are covered by #569.

A problem could be that the Includes in /etc/ssh/ssh_config.d are not considered with the current implementation of #569. Maybe we can consider supporting the recursive includes, but I'm not sure if we would do that here. The ssh completion provided here is a kind of a lightweight version of bash-completion, and we already have a full implementation for this processing in the upstream (scop/bash-completion#80 and scop/bash-completion#976). Users who request a certain level of quality should consider move to bash-completion.

@RobLoach
Copy link
Contributor

RobLoach commented Sep 30, 2024

@akinomyoga Speaking of scop/bash-completion , what is the best way to include that? I've added a small bash.completion.sh plugin...

#! bash oh-my-bash.module
#
# bash-completion
# https://github.com/scop/bash-completion

if [[ $PS1 ]]; then
	# Use _omb_util_command_exists() for bash_completion's have() command
	have()
	{
		unset -v have
		_omb_util_command_exists "$1"
	}

	# Custom BASH_COMPLETION_DIR
	if [[ -f ${BASH_COMPLETION_DIR}/bash_completion ]]; then
		. ${BASH_COMPLETION_DIR}/bash_completion
	# Config directory
	elif [[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion/bash_completion" ]]; then
		. ${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion/bash_completion
	# /usr/share/bash-completion
	elif [[ -f /usr/share/bash-completion/bash_completion ]]; then
		. /usr/share/bash-completion/bash_completion
	# /sw/etc/bash_completion
	elif [[ -f /sw/etc/bash_completion/bash_completion ]]; then
		. /sw/etc/bash_completion/bash_completion
	fi

	# The have() command is no longer needed
	unset -v have
fi

@akinomyoga
Copy link
Contributor

It's already loaded as a default set of configurations:

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [[ -f /usr/share/bash-completion/bash_completion ]]; then
. /usr/share/bash-completion/bash_completion
elif [[ -f /etc/bash_completion ]]; then
. /etc/bash_completion
fi
fi

However, there is an open PR #572 to move it to a plugin.

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

No branches or pull requests

3 participants