One of my favourite things about fish is the intelligent tab
completion. Today, when I was going to use ssh, I noticed that it does
some neat tab-completion on hostnames. However there was a short lag
when I hit tab and then a huge number of hostnames were shown.

Then I realized that only the top of my /etc/hosts file is legit
hosts, the bottom 99.9% are addresses that I am blocking using the
hosts file I got from http://www.hostsfile.org/hosts.html. fish was
using those for the tab completion as well (why wouldn't it).

I did up a little fix for it. It is simple, but I figured that I would
share it anyway, incase any of you are also using your hosts file in
this way.

First I added this line to my /etc/hosts file just about where the
bad-hosts list starts:
# fish-ignore-rest

Then I modified my __fish_print_hostnames.fish file with this:
#################
--- __fish_print_hostnames.fish.old     2007-03-15 00:23:00.000000000 -0300
+++ __fish_print_hostnames.fish 2007-03-15 00:21:47.000000000 -0300
@@ -3,7 +3,7 @@

        # Print all hosts from /etc/hosts
        if test -f /etc/hosts
-               sed </etc/hosts -e 's/[0-9.]*\( \|\t\)*\(.*\)/\2/'|sed
-e 's/\#.*//'|tr \t \n |grep -v '^$'
+               sed -n '1,/fish-ignore-rest/p' | sed </etc/hosts -e
's/[0-9.]*\( \|\t\)*\(.*\)/\2/'|sed -e 's/\#.*//'|tr \t \n |grep -v
'^$'
        end
        # Print nfs servers from /etc/fstab
        if test -f /etc/fstab
#################

Now the tab completion is much quicker and only uses my "real" hosts.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to