From 60248e895f92a37d61fde60feba63fe01f1ef112 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 8 Nov 2017 12:52:16 +0100 Subject: [PATCH] Use __fish_complete_user_at_hosts for various completions. This makes the code a bit nicer, removes one of the __fish_print_hostnames calls (which are slow) and a sed call, thereby improving performance by about 33% (600ms to 400ms). Fixes #4511. --- share/completions/mosh.fish | 10 +--------- share/completions/scp.fish | 8 +------- share/completions/ssh.fish | 9 +-------- share/completions/sshfs.fish | 14 +------------- 4 files changed, 4 insertions(+), 37 deletions(-) diff --git a/share/completions/mosh.fish b/share/completions/mosh.fish index 1aa92f895..36a00b36f 100644 --- a/share/completions/mosh.fish +++ b/share/completions/mosh.fish @@ -1,13 +1,5 @@ -complete -x -c mosh -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) -" +complete -x -c mosh -d Hostname -a "(__fish_complete_user_at_hosts)" complete -x -c mosh -d User -a " (__fish_print_users)@ diff --git a/share/completions/scp.fish b/share/completions/scp.fish index f6c959198..73e4bb552 100644 --- a/share/completions/scp.fish +++ b/share/completions/scp.fish @@ -30,13 +30,7 @@ end # Hostname # complete -c scp -d Hostname -n "commandline --cut-at-cursor --current-token | string match -v '*:*'" -a " -(__fish_print_hostnames): - -( - #Prepend any username specified in the completion to the hostname - commandline -ct |sed -ne 's/\(.*@\).*/\1/p' -)(__fish_print_hostnames): -" +(__fish_complete_user_at_hosts):" # # Local path diff --git a/share/completions/ssh.fish b/share/completions/ssh.fish index f9f4dc328..b90c7117e 100644 --- a/share/completions/ssh.fish +++ b/share/completions/ssh.fish @@ -6,14 +6,7 @@ __fish_complete_ssh ssh # # ssh specific completions # -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) -" +complete -x -c ssh -d Hostname -a "(__fish_complete_user_at_hosts)" # Disable as username completion is not very useful. # complete -x -c ssh -d User -a " diff --git a/share/completions/sshfs.fish b/share/completions/sshfs.fish index 88de8db3b..1f224b0fe 100644 --- a/share/completions/sshfs.fish +++ b/share/completions/sshfs.fish @@ -1,19 +1,7 @@ # # Completions for sshfs # -# Host combinations, borrowed from ssh.fish -# -complete -x -c sshfs -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): - -(__fish_print_users)@ -" +complete -x -c sshfs -d Hostname -a "(__fish_complete_user_at_hosts):" # # Mount Points #