[Bash-completion-devel] Bug#689585: ssh: please don't complete hosts found after Hostname in .ssh/config

Uwe Kleine-König uwe+debian at kleine-koenig.org
Thu Oct 4 08:38:40 UTC 2012

Package: bash-completion
Version: 1:2.0-1
Severity: minor


my ssh-config contains something like:

	Host login.sd
	Hostname login.some.domain
	ProxyCommand none

	Host somehost.sd
	Hostname somehost.some.domain

	Host *.sd
	ProxyCommand ssh login.sd nc -w 1 %h %p

So now if I type

	$ ssh someho<tab>

I'd like to only getting somehost.sd suggested, because I cannot connect
to somehost.some.domain directly anyhow.

So I suggest to do

-        local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" )
+        local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\1/p' "${config[@]}" )

in /usr/share/bash-completion/bash_completion.

Obviously this changes the result for people that want the names after
Hostname completed. For those you can just add an otherwise empty Host

Best regards

-- System Information:
Debian Release: 6.0.5
  APT prefers stable-updates
  APT policy: (900, 'stable-updates'), (900, 'proposed-updates'), (900, 'stable'), (800, 'testing-proposed-updates'), (800, 'testing'), (700, 'unstable'), (600, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages bash-completion depends on:
ii  bash                          4.1-3      The GNU Bourne Again SHell
ii  dpkg                          1.16.8     Debian package management system

bash-completion recommends no packages.

bash-completion suggests no packages.

-- no debconf information

More information about the Bash-completion-devel mailing list