Last active
September 8, 2021 00:18
-
-
Save tahir-hassan/17785c22364c64fa26aca51ed092e4c8 to your computer and use it in GitHub Desktop.
A script that enables you to use Alt+F4 to exit the PowerShell instance.
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
Set-PSReadLineKeyHandler -Key 'Alt+F4' ` | |
-BriefDescription ExitPowerShell ` | |
-LongDescription "Exits PowerShell" ` | |
-ScriptBlock { | |
param($key, $arg) | |
$line = $null; | |
$cursor = $null; | |
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref] $line, [ref] $cursor); | |
[Microsoft.PowerShell.PSConsoleReadLine]::Delete(0, $line.Length); | |
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("exit"); | |
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine($null, $null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment