Add interface label/name to the completions for -b

This commit is contained in:
Jason Nader
2020-01-25 15:54:49 +09:00
committed by Fabian Homborg
parent d29bc720cd
commit 3142ef6dbc

View File

@@ -18,7 +18,19 @@ complete -c ssh -n 'test (__fish_number_of_cmd_args_wo_opts) -ge 2' -d "Command
complete -c ssh -s a -d "Disables forwarding of the authentication agent"
complete -c ssh -s A -d "Enables forwarding of the authentication agent"
complete -x -c ssh -s b -d "Local address to bind to" -a "(__fish_print_addresses)"
function __ssh_print_local_addresses_with_labels
if command -sq ip
command ip --oneline address | string replace -r '\d+:\s+(\S+)\s+\S+\s+(.+)/.*' '$2\t$1'
else if command -sq ifconfig
# This is for OSX/BSD/anything else that doesn't have `ip` installed.
# Since ifconfig output is not guaranteed to be the same on these systems,
# for now we will limit the completions to just the IP address.
# TODO: check ifconfig output on each system and rework below to include label.
ifconfig | awk '/^\tinet/ { print $2 } '
end
end
complete -x -c ssh -s b -d "Local address to bind to" -a '(__ssh_print_local_addresses_with_labels)'
complete -x -c ssh -s e -d "Escape character" -a "\^ none"
complete -c ssh -s f -d "Go to background"