Last active
March 23, 2022 16:07
-
-
Save pulimento/ddd82080232360a49a2e4c751bf16515 to your computer and use it in GitHub Desktop.
Colorize PowerShell's adb output
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
# Change execution policy: Set-ExecutionPolicy -Scope Process Unrestricted | |
# Run this script, and then 'adb logcat | color-logcat' | |
Function global:color-logcat { | |
Process { | |
if ($_) { | |
$color = "White" | |
$fgcolor = "Black" | |
if($_ -match [regex]"\s[V]\s") { | |
$color = "Gray" | |
#$fgcolor = "DarkBlue" | |
} | |
elseif($_ -match [regex]"\s[D]\s") { | |
$color = "Green" | |
#$fgcolor = "DarkBlue" | |
} | |
elseif($_ -match [regex]"\s[I]\s") { | |
$color = "Cyan" | |
#$fgcolor = "DarkBlue" | |
} | |
elseif($_ -match [regex]"\s[W]\s") { | |
$color = "DarkYellow" | |
#$fgcolor = "Blue" | |
} | |
elseif($_ -match [regex]"\s[E]\s") { | |
$color = "Red" | |
#$fgcolor = "Blue" | |
} | |
elseif($_ -match [regex]"\s[F]\s") { | |
$color = "Magenta" | |
#$fgcolor = "Blue" | |
} | |
# Removes date | |
write-host $_.Remove(0,6) -foregroundcolor $color -backgroundcolor $fgcolor | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment