Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
A wish list entry as discussed in issue #4374:
In my case:
Most entries have one or more IPs in addition to hostnames, some have multiple hostnames.
~/.ssh/config has multiple entries (some with multiple hostnames), too:
Timing is done with:
Which yields 0.32s (best of multiple runs) on Intel Xeon CPU E5-2620 @ 2.10GHz
For comparison: bash performs completion here without any noticeable delay.
So.... there's a bunch of stuff we can do here. Some is general and requires a bunch of work, some is specific to the ssh completion script and the
The biggest one is this:
complete -x -c ssh -d Hostname -a " (__fish_print_hostnames) ( # Prepend any username specified in the completion to the hostname echo (commandline -ct)|sed -ne 's/\(.*@\).*/\1/p' )(__fish_print_hostnames) "
That actually calls
For more improvement, we need profiling. Fortunately fish has that built-in. Unfortunately it's not accessible from inside a running session, so this will include fish's startup time (and yes, we have issues open about that). It will also include an error since the
On my system, about 90% of the time spent in
@ThomasAH: Please run
Full profile attached. There is nothing private in it, the only information that some people might consider private is the location of my home directory and that I use fish's vi mode :)
Edit: It seems I can't attach the profile here. Here is the output of
Anyway, I'm going to open a PR any minute now that could possibly improve stuff somewhat.
I've tested @ThomasAH's awk script from #4378 under FreeBSD with the BSD
I've merged it into both master and 2.7.0
My solution to problem works like a charm:
domas.zelionis@eng ~> cat /etc/hosts_for_fish |wc -l
domas.zelionis@eng ~> date --iso-8601=ns ;__fish_print_hostnames > /dev/null;date --iso-8601=ns;
function __fish_print_hostnames -d "Print a list of known hostnames"