Skip to content

Instantly share code, notes, and snippets.

View thiennn-neji's full-sized avatar

Thien Nguyen-Ngoc thiennn-neji

  • Vietnam
View GitHub Profile
@thiennn-neji
thiennn-neji / ssh-argument-complete-snippet.ps1
Last active November 16, 2022 16:45
Enable tab completion for ssh hostnames in PowerShell
using namespace System.Management.Automation
Register-ArgumentCompleter -CommandName ssh,scp,sftp -Native -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
function Get-SSHHostList($sshConfigPath) {
Get-Content -Path $sshConfigPath `
| Select-String -Pattern '^Host ' `
| ForEach-Object { $_ -replace 'Host ', '' } `
| ForEach-Object { $_ -split ' ' } `