Created
September 6, 2025 18:27
-
-
Save trackd/e470d5976d8205afcd191a2bc0ef996b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function Send-Completion { | |
| <# | |
| https://github.com/microsoft/terminal/wiki/Experimental-Shell-Completion-Menu | |
| #> | |
| [CmdletBinding()] | |
| param() | |
| try { | |
| $a = [char]7 # BEL, `a | |
| $e = [char]27 # ESC, `e | |
| $InputString = [string]::Empty | |
| $CursorIndex = 0 | |
| [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$InputString, [ref]$CursorIndex) | |
| $sb = [Text.StringBuilder]::new().Append("$e]633;Completions") | |
| if (-Not [String]::IsNullOrEmpty($InputString)) { | |
| $CompletionResults = TabExpansion2 -inputScript $InputString -cursorColumn $CursorIndex | |
| if ($CompletionResults.CompletionMatches) { | |
| [void] $sb. | |
| AppendFormat( | |
| ';{0};{1};{2};', | |
| $CompletionResults.ReplacementIndex, | |
| $CompletionResults.ReplacementLength, | |
| $CursorIndex | |
| ). | |
| Append( | |
| ($CompletionResults.CompletionMatches | ConvertTo-Json -Compress) | |
| ) | |
| } | |
| } | |
| Write-Host -NoNewline $sb.Append($a).ToString() | |
| } | |
| catch { | |
| throw | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment