2005-09-20 21:31:55 +08:00
|
|
|
#
|
2017-02-02 14:49:40 +08:00
|
|
|
# Load completions shared by ssh and scp.
|
2005-09-20 21:31:55 +08:00
|
|
|
#
|
2006-02-15 10:22:28 +08:00
|
|
|
__fish_complete_ssh ssh
|
2005-09-20 21:31:55 +08:00
|
|
|
|
2017-02-02 14:49:40 +08:00
|
|
|
#
|
|
|
|
# ssh specific completions
|
|
|
|
#
|
2020-03-10 02:36:12 +08:00
|
|
|
complete -x -c ssh -d Remote -a "(__fish_complete_user_at_hosts)"
|
2009-02-02 07:18:05 +08:00
|
|
|
|
2017-02-02 14:49:40 +08:00
|
|
|
# Disable as username completion is not very useful.
|
2017-01-26 10:03:36 +08:00
|
|
|
# complete -x -c ssh -d User -a "
|
|
|
|
# (__fish_print_users | string match -r -v '^_')@
|
|
|
|
# "
|
2005-09-20 21:31:55 +08:00
|
|
|
|
2019-11-05 17:56:03 +08:00
|
|
|
complete -c ssh -n 'test (__fish_number_of_cmd_args_wo_opts) -ge 2' -d "Command to run" -x -a '(__fish_complete_subcommand --fcs-skip=2)'
|
2017-02-02 14:49:40 +08:00
|
|
|
|
|
|
|
complete -c ssh -s a -d "Disables forwarding of the authentication agent"
|
|
|
|
complete -c ssh -s A -d "Enables forwarding of the authentication agent"
|
2020-01-25 01:29:17 +08:00
|
|
|
|
2020-01-25 14:54:49 +08:00
|
|
|
|
|
|
|
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)'
|
2005-09-20 21:31:55 +08:00
|
|
|
|
2017-02-02 14:49:40 +08:00
|
|
|
complete -x -c ssh -s e -d "Escape character" -a "\^ none"
|
|
|
|
complete -c ssh -s f -d "Go to background"
|
|
|
|
complete -c ssh -s g -d "Allow remote host to connect to local forwarded ports"
|
|
|
|
complete -c ssh -s I -d "Smartcard device"
|
|
|
|
complete -c ssh -s k -d "Disable forwarding of Kerberos tickets"
|
2020-03-10 02:36:12 +08:00
|
|
|
complete -c ssh -s l -x -a "(__fish_complete_users)" -d User
|
2017-02-02 14:49:40 +08:00
|
|
|
complete -c ssh -s m -d "MAC algorithm"
|
|
|
|
complete -c ssh -s n -d "Prevent reading from stdin"
|
|
|
|
complete -c ssh -s N -d "Do not execute remote command"
|
2020-03-10 02:36:12 +08:00
|
|
|
complete -c ssh -s p -x -d Port
|
2017-02-02 14:49:40 +08:00
|
|
|
complete -c ssh -s q -d "Quiet mode"
|
2020-03-10 02:36:12 +08:00
|
|
|
complete -c ssh -s s -d Subsystem
|
2017-02-02 14:49:40 +08:00
|
|
|
complete -c ssh -s t -d "Force pseudo-tty allocation"
|
|
|
|
complete -c ssh -s T -d "Disable pseudo-tty allocation"
|
|
|
|
complete -c ssh -s x -d "Disable X11 forwarding"
|
|
|
|
complete -c ssh -s X -d "Enable X11 forwarding"
|
|
|
|
complete -c ssh -s L -d "Locally forwarded ports"
|
|
|
|
complete -c ssh -s R -d "Remotely forwarded ports"
|
|
|
|
complete -c ssh -s D -d "Dynamic port forwarding"
|
2019-04-23 04:17:09 +08:00
|
|
|
complete -c ssh -s c -d "Encryption cipher" -xa "(ssh -Q cipher)"
|
2018-04-13 10:40:10 +08:00
|
|
|
|
2020-01-25 01:29:17 +08:00
|
|
|
# Also retrieve `user@host` entries from history
|
2020-09-19 17:39:51 +08:00
|
|
|
function __ssh_history_completions --argument-names limit
|
2019-05-05 18:53:09 +08:00
|
|
|
if string match -q ""
|
|
|
|
set limit 100
|
|
|
|
end
|
2018-04-13 10:40:10 +08:00
|
|
|
|
2020-01-25 01:29:17 +08:00
|
|
|
history --prefix ssh | string replace -rf '.* ([A-Za-z0-9._:-]+@[A-Za-z0-9._:-]+).*' '$1' | head -n $limit
|
2018-04-13 10:40:10 +08:00
|
|
|
end
|
|
|
|
|
2020-03-10 02:36:12 +08:00
|
|
|
complete -k -c ssh -a '(__ssh_history_completions 100)' -f -d Remote
|