Initial commit.

This commit is contained in:
Mikael CAPELLE
2022-08-16 08:43:25 +02:00
commit 18bbe73ca8
5 changed files with 320 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
if (Get-Module posh-ssh) {
return
}
$cmdNames = "ssh"
$cmdNames += Get-Alias -Definition $cmdNames -ErrorAction Ignore | ForEach-Object Name
$configFile = "$env:USERPROFILE/.ssh/config"
Register-ArgumentCompleter -CommandName $cmdNames -Native -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
Get-Content $configFile | Select-String -Pattern "^Host(\s+([.A-Za-z0-9\-_]+))+\s*$" | ForEach-Object {
$_.Matches.Groups[2].Captures.Value
} | Where-Object {
$_ -like "$wordToComplete*"
} | ForEach-Object {
"$_"
}
}