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.
This commit is contained in:
Fabian Homborg 2017-11-08 12:52:16 +01:00
parent 45fc499a91
commit 60248e895f
4 changed files with 4 additions and 37 deletions

View file

@ -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)@

View file

@ -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

View file

@ -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 "

View file

@ -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
#