Initial commit.
This commit is contained in:
20
Modules/posh-ssh/posh-ssh.psm1
Normal file
20
Modules/posh-ssh/posh-ssh.psm1
Normal 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 {
|
||||
"$_"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user