Verified Commit 6407cefe authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add SSH hosts from config to term-startup.sh

parent 49fe2de0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -92,3 +92,6 @@
[submodule ".vim/bundle/vim-jq"]
	path = .vim/bundle/vim-jq
	url = https://github.com/bfrg/vim-jq
[submodule ".vim/bundle/nvim-lspconfig"]
	path = .vim/bundle/nvim-lspconfig
	url = https://github.com/neovim/nvim-lspconfig
+1 −3
Original line number Diff line number Diff line
@@ -52,9 +52,7 @@ do_ssh() {
	local host args

	if [[ ! -v SSH_HOSTS ]]; then
		local IFS=$'\n',
		cut -f1 -d ' ' <~/.ssh/known_hosts |
			read -d '' -a SSH_HOSTS || true
		ssh_hosts | read -d '' -a SSH_HOSTS || true
	fi

	read_completions \
+21 −0
Original line number Diff line number Diff line
@@ -20,9 +20,30 @@ ssh_version() {
	return 1
}

ssh_hosts() {
	[ -n "$SSH_CONFIG" ] || make_config
	local state=ignore token
	{
		sed 's/[ ].*//; s/,/\n/g' ~/.ssh/known_hosts
		sed -n '/^\(match\|host\) /I { s/.*/\l\0/; s/\s\+/\n/g; p; }' "$SSH_CONFIG" |
		while read token; do
			case $token in
				all|canonical|final) continue ;;
				host|originalhost) state=take ;;
				match|exec|user|localuser) state=ignore ;;
				*) [ $state = take ] && echo "$token" ;;
			esac
		done |
		command grep '^[a-zA-Z0-9]\+\([.][a-zA-Z0-9]+\)*$'
	} | sort -u
}

make_config() {
	ssh_version || return 1

	SSH_CONFIG=$HOME/.ssh/config
	export SSH_CONFIG

	# SSH >=7.3 does not need a filtered config
	[ $SSH_MAJOR -gt 7 ] && return
	[ $SSH_MAJOR -eq 7 ] && [ $SSH_MINOR -ge 3 ] && return
Original line number Diff line number Diff line
Subproject commit ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57