Last active
July 13, 2021 11:20
-
-
Save Morten242/018f83ccb58b69e75f5789a15767a5da to your computer and use it in GitHub Desktop.
Ninja tab-completion for PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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