Skip to content

Instantly share code, notes, and snippets.

@pulimento
Last active March 23, 2022 16:07
Show Gist options
  • Save pulimento/ddd82080232360a49a2e4c751bf16515 to your computer and use it in GitHub Desktop.
Save pulimento/ddd82080232360a49a2e4c751bf16515 to your computer and use it in GitHub Desktop.
Colorize PowerShell's adb output
# 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