mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-26 03:35:17 +00:00
Improve completions for ssh
by completing from history
This commit is contained in:
parent
14d59c53f6
commit
facdc88c0c
2 changed files with 12 additions and 0 deletions
|
@ -69,6 +69,7 @@ This section is for changes merged to the `major` branch that are not also merge
|
||||||
- `brew`
|
- `brew`
|
||||||
- `diskutil`
|
- `diskutil`
|
||||||
- `yarn`
|
- `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 L -d "Locally forwarded ports"
|
||||||
complete -c ssh -s R -d "Remotely forwarded ports"
|
complete -c ssh -s R -d "Remotely forwarded ports"
|
||||||
complete -c ssh -s D -d "Dynamic port forwarding"
|
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
|
||||||
|
|
Loading…
Reference in a new issue