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

Add support for ANSI escape sequences (e.g. colors) #5

Open
Pauan opened this issue Sep 9, 2015 · 9 comments
Open

Add support for ANSI escape sequences (e.g. colors) #5

Pauan opened this issue Sep 9, 2015 · 9 comments

Comments

@Pauan
Copy link

Pauan commented Sep 9, 2015

I tried many different script runners, including run-in-terminal, termrk, terminal-panel, term, quantum-shell, etc.

Sadly, except for term, they're all broken. So far, yours is the best for fulfilling my particular needs.


However, there is one feature I would like: the ability to show ANSI color escapes.

Here is how it looks when I run the command in my terminal: (screenshot)

And here is how it looks when I run the same command in process-palette: (screenshot)

@morassman
Copy link
Owner

I'd really like to do this. Relative to the other issues I'm going to give this one a lower priority, but at some point I'd like to start looking into it.

@Pauan
Copy link
Author

Pauan commented Sep 10, 2015

That's fine, I understand that this is a "nice-to-have" feature, and not a necessity.

tty.js has support for ANSI colors, maybe it would be possible to grab their implementation and use it?

@morassman
Copy link
Owner

@toddmazierski recently added support for ANSI colour escape sequences. v0.5.4 includes it. Try it out. It might not give you the output as shown in the screenshot from your terminal. This change should only add colours, but other control sequences, such as moving the cursor around on the screen, are not supported.

@Pauan
Copy link
Author

Pauan commented Nov 25, 2015

I just upgraded to Atom version 1.2.4 and process-palette version 0.5.4, but the colors are not showing up in process-palette: it's the same as before.

@morassman
Copy link
Owner

Ok. Thanks for testing it. I've been testing it a bit more myself and the only time I actually get colours out is if I do an "echo" with escape sequences hard-coded in, but when running any other process I don't get any colours either. I'll dig a bit into it...

@toddmazierski
Copy link
Contributor

Hi @Pauan and @morassman,

By default, most command line utilities (correctly) automatically disable colors if they detect a non-interactive (non-tty) shell. Most, however, offer arguments or config flags to override this behavior.

For example, for colors to appear for npm, you can pass --color=always (documentation):

screen shot 2015-11-25 at 10 06 23 am

@morassman
Copy link
Owner

That makes sense. Thanks @toddmazierski. @Pauan did suggest I look at tty.js. Perhaps it fools the process into thinking that it's an interactive shell, which then has the desired effect.

FYI. Process Palette uses shelljs to run commands and I saw that there has been a feature request for this. If this gets done for shelljs it should "just work" thanks to the changes you made. When I get time I'll also look at how tty.js did things.

PS. From your screenshot it looks like it would be useful to be able to configure the background colour. Perhaps making the background colour black by default would also help.

@Pauan
Copy link
Author

Pauan commented Nov 30, 2015

@toddmazierski Thank you for the explanation.

Using npm --color=always run-script build and webpack --colors does work.


@morassman Yes, the ability to customize the background color and font color would be very nice.

I think the default should be black and white, respectively.


Also, I noticed this: (screenshot)

It's including the ANSI color escapes (e.g. [34m) in the output.

I'm not sure what the best way to fix this is: either colorizing the output so it displays proper colors, or stripping out the ANSI color escapes.

@lucidNTR
Copy link

+1 for showing correct colors in process palette, extremely helpfull for running large test suites...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants