Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Powershell console colors #39

Closed
neilknowscomputers opened this issue Jan 13, 2015 · 4 comments
Closed

Support Powershell console colors #39

neilknowscomputers opened this issue Jan 13, 2015 · 4 comments
Labels

Comments

@neilknowscomputers
Copy link

Powershell supports colors in its console output similar to other shells a la

Write-Host "Blue on Green!" -ForegroundColor Blue -BackgroundColor Green

It would be pretty freaking awesome if Powershell scripts run in Jenkins would display these output color choices. I am not a Java developer personally, but if this is easy enough to do I could take a swing at it. I could certainly test the feature if someone else implemented it.

@ejelly
Copy link
Collaborator

ejelly commented Jan 25, 2015

It's more about bringing PowerShell to output the proper color escape codes, which the ansicolor plugin would interpret and translate into HTML. I'm not sure if that's possible, a quick search lead to nothing obvious. It may very well be that the PowerShell drives the Windows Terminal directly with some API when run within it, instead of outputting escape codes which would then be parsed.

You can do the research to see if PowerShell can color its output using escape codes. If it can, then you might be lucky in that ansicolor supports them already. If there are unsupported ones, we might take shot at implementing them. But as said, that all depends on PowerShell actually outputting the color information.

@Stefan-Hanke
Copy link

No it doesn't. I checked this by putting that line of PowerShell script into a file and ran the equivalent of powershell ./test.ps1 and observed the output. It's just the raw characters, no escape sequences whatsoever.

Just digging around a little bit:

The solution depends on whether one can write escape sequences to standard output at all. If true, the simplest solution is to replace calls to Write-Host with a custom function, emitting the proper escape sequences. If you can't change the code, there is a way to change what Write-Host does via cmdlet proxies.

Even easier seems to just redefine Write-Host to a function that internally uses Write-Output. Might be worth a shot. Seen on SO somewhere but alas lost the link...

function global:Write-Host() { }

Mayhaps the scripts could be wrapped before execution...

@vzabawski
Copy link

@stale
Copy link

stale bot commented May 28, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 28, 2021
@stale stale bot closed this as completed Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants