Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HumanEquivalentUnit/c00db7ceb2fdba17931145e27c71b0ee to your computer and use it in GitHub Desktop.
Save HumanEquivalentUnit/c00db7ceb2fdba17931145e27c71b0ee to your computer and use it in GitHub Desktop.
Bodge-add binary literal number support to PowerShell
$ExecutionContext.InvokeCommand.CommandNotFoundAction = {
param($Name,[System.Management.Automation.CommandLookupEventArgs]$CommandLookupArgs)
$CommandLookupArgs.CommandScriptBlock = {
if ($CommandLookupArgs.CommandName -match '(?<binary>1[10]*)b$')
{
[convert]::ToInt32($matches['binary'], 2)
}
}.GetNewClosure()
}
1b
10b
11b
100b
101b
110b
111b
1000b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment