Ville Skyttä c506b6
--- a/bash_completion
Ville Skyttä c506b6
+++ b/bash_completion
Ville Skyttä 1841a5
@@ -1259,16 +1259,16 @@ _known_hosts_real()
Ville Skyttä 1841a5
         awkcur=${awkcur//\./\\\.}
Ville Skyttä 1841a5
         curd=$awkcur
Ville Skyttä 1841a5
 
Ville Skyttä 1841a5
-        if [[ "$awkcur" == [0-9]*.* ]]; then
Ville Skyttä 1841a5
-            # Digits followed by a dot - just search for that
Ville Skyttä 1841a5
-            awkcur="^$awkcur.*"
Ville Skyttä 1841a5
+        if [[ "$awkcur" == [0-9]*[.:]* ]]; then
Ville Skyttä 1841a5
+            # Digits followed by a dot or a colon - just search for that
Ville Skyttä 1841a5
+            awkcur="^$awkcur[.:]*"
Ville Skyttä 1841a5
         elif [[ "$awkcur" == [0-9]* ]]; then
Ville Skyttä 1841a5
-            # Digits followed by no dot - search for digits followed
Ville Skyttä 1841a5
-            # by a dot
Ville Skyttä 1841a5
-            awkcur="^$awkcur.*\."
Ville Skyttä 1841a5
+            # Digits followed by no dot or colon - search for digits followed
Ville Skyttä 1841a5
+            # by a dot or a colon
Ville Skyttä 1841a5
+            awkcur="^$awkcur.*[.:]"
Ville Skyttä 1841a5
         elif [ -z "$awkcur" ]; then
Ville Skyttä 1841a5
-            # A blank - search for a dot or an alpha character
Ville Skyttä 1841a5
-            awkcur="[a-z.]"
Ville Skyttä 1841a5
+            # A blank - search for a dot, a colon, or an alpha character
Ville Skyttä 1841a5
+            awkcur="[a-z.:]"
Ville Skyttä 1841a5
         else
Ville Skyttä 1841a5
             awkcur="^$awkcur"
Ville Skyttä 1841a5
         fi
Ville Skyttä 1841a5
@@ -1278,8 +1278,7 @@ _known_hosts_real()
Ville Skyttä c506b6
             COMPREPLY=( "${COMPREPLY[@]}" $( awk 'BEGIN {FS=","}
Ville Skyttä c506b6
             /^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
Ville Skyttä c506b6
             gsub(" .*$", "", $i); \
Ville Skyttä c506b6
-            gsub("[\\[\\]]", "", $i); \
Ville Skyttä c506b6
-            gsub(":[0-9]+$", "", $i); \
Ville Skyttä c506b6
+            sub("^\\[", "", $i); sub("\\](:[0-9]+)?$", "", $i); \
Ville Skyttä c506b6
             if ($i ~ /'"$awkcur"'/) {print $i} \
Ville Skyttä c506b6
             }}' "${kh[@]}" 2>/dev/null ) )
Ville Skyttä c506b6
         fi