mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-27 00:21:15 -03:00
Improve completions for ssh by completing from history
This commit is contained in:
@@ -69,6 +69,7 @@ This section is for changes merged to the `major` branch that are not also merge
|
||||
- `brew`
|
||||
- `diskutil`
|
||||
- `yarn`
|
||||
- `ssh` (#4344)
|
||||
|
||||
--
|
||||
|
||||
|
||||
@@ -41,3 +41,14 @@ 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"
|
||||
|
||||
# Also look up hosts from the history
|
||||
function __ssh_history_completions --argument limit
|
||||
if string match -q ""
|
||||
set limit 100
|
||||
end
|
||||
|
||||
history --prefix ssh | sed -n "s/.* \([A-Za-z0-9._:-]\+@[A-Za-z0-9._:-]\+\).*/\1/p" | head -n $limit
|
||||
end
|
||||
|
||||
complete -k -c ssh -a '(__ssh_history_completions 100)' -f
|
||||
|
||||
Reference in New Issue
Block a user