diff --git a/CHANGELOG.md b/CHANGELOG.md index 581f8aea4..42c1d56fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ This section is for changes merged to the `major` branch that are not also merge - `brew` - `diskutil` - `yarn` + - `ssh` (#4344) -- diff --git a/share/completions/ssh.fish b/share/completions/ssh.fish index 4950b2082..6d8249df1 100644 --- a/share/completions/ssh.fish +++ b/share/completions/ssh.fish @@ -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