Skip to content

Instantly share code, notes, and snippets.

View msftrncs's full-sized avatar

Carl Morris msftrncs

  • Rosenbauer Aerials LLC
  • Nebraska, USA
View GitHub Profile
@msftrncs
msftrncs / GitSafeDirectoryTools.ps1
Last active April 15, 2022 00:22
PowerShell functions to automate Git `safe.directory` submission
function Find-GitDirectory {
param (
[string[]] $Path = '.',
[switch] $Recurse
)
$gciParams = @{
Recurse = $Recurse
Force = $true
@msftrncs
msftrncs / Format-Bytes.ps1
Last active December 1, 2021 20:42
Format-Bytes: My Version
filter Format-Bytes {
if ($_ -is [ValueType]) {
$x = if (0 -ne $_) {
[Math]::Min([int][Math]::Truncate([Math]::Log([Math]::Abs($_), 1kb)), 8)
} else {
0
}
if ($x -eq 0) {
"$_ B"
} else {
@msftrncs
msftrncs / @msftrncs_workingOn.md
Last active September 19, 2019 00:27
What is @msftrncs working on?
@msftrncs
msftrncs / PSReadLineProfile.ps1
Last active November 30, 2021 20:24
PSReadLine profile options
Set-PSReadLineOption -Colors @{
Command = 'DarkYellow'
Comment = 'DarkGray'
Keyword = 'Magenta'
Member = 'White'
Number = 'Cyan'
Operator = 'Blue'
Parameter = 'Yellow'
String = 'Green'
Type = 'Red'
@msftrncs
msftrncs / PSRequiresQuotes.ps1
Last active November 5, 2019 07:28
PowerShell (v6.2+) filter to quote arguments in order to use them in command line completions
using namespace System.Management.Automation.Language
function CmdRequiresQuote ([string]$in) {
[QuoteCheck]::CmdRequiresQuote($in, $false)
}
function CmdRequiresQuote ([string]$in, [bool]$IsExpandable = $false) {
[Token[]]$_tokens = $null
(_CommonRequiresQuote $in $IsExpandable ([ref]$_tokens)) -or
-not $IsExpandable -and ($_tokens[0].Kind -in (