Skip to content

Instantly share code, notes, and snippets.

@Morten242
Last active July 13, 2021 11:20
Show Gist options
  • Save Morten242/018f83ccb58b69e75f5789a15767a5da to your computer and use it in GitHub Desktop.
Save Morten242/018f83ccb58b69e75f5789a15767a5da to your computer and use it in GitHub Desktop.
Ninja tab-completion for PowerShell
$ninjaCompleteBlock = {
param($wordToComplete, $commandAst, $cursorPosition)
$toComplete = [Regex]::Escape($wordToComplete)
Select-String .\build.ninja -pattern "^build ($toComplete[\w-]*[\\/]?)[\w-]*:"
| ForEach-Object { $_.Matches.Groups[1].Value.Trim() }
| Sort-Object -CaseSensitive
}
Register-ArgumentCompleter -CommandName ninja -Native -ScriptBlock $ninjaCompleteBlock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment