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

Colour not being shown in Windows command prompt #23

Closed
Praful opened this issue Apr 23, 2014 · 7 comments · Fixed by #33
Closed

Colour not being shown in Windows command prompt #23

Praful opened this issue Apr 23, 2014 · 7 comments · Fixed by #33

Comments

@Praful
Copy link

Praful commented Apr 23, 2014

Instead of seeing colours, I'm seeing the escape sequence ←[1;33m10768←[0m←. I also get the same in another command prompt I use (ConEmu).

If it helps, ack shows colours correctly but ag doesn't!

@monochromegane
Copy link
Owner

I have changed default color option to disable on Windows.

Although I don't know how to detect if the console does support ANSI escape codes in Golang,
ANSICON that supports ANSI escape codes sets ANSICON environment variables.

So, If ANSICON environment variables is found, default color option become enable.

@monochromegane
Copy link
Owner

If you want to show color, you can specify --color option.

@Praful
Copy link
Author

Praful commented Apr 25, 2014

I just downloaded Golang and tried several ANSI packages for it. None of them worked!

One of them (github.com/fatih/color) has Windows support on the todo list.

ANSICON works but it doesn’t play well with my default console (ConEmu). However, ConEmu has ANSI support and pt is working with it although I’m struggling to get ANSI support and readline support (via clink) to work.

So far, only ack correctly allows colours in the Windows 7 command prompt so Perl must be doing something right! A clue might be what someone said about the above package:

Please, for the sake of sanity and portability, do not output escape sequences directly. Instead, if possible try to use terminfo or termcap to figure out what the appropriate escape sequence is. This makes it much easier to use your package on terminals with weird escape sequences.

You can read the thread here.

@Praful Praful closed this as completed Apr 25, 2014
@Praful Praful reopened this Apr 25, 2014
@monochromegane
Copy link
Owner

Thanks, I try to read the thread and ack's source.

@Praful
Copy link
Author

Praful commented May 3, 2014

I'd like to set default options for pt instead of typing them each time I run it, such as defaulting to /i /color. Is there a way of doing this eg using an environment variable?

@monochromegane
Copy link
Owner

Hi, @Praful .
@shiena gave me a solution by using his package in this pull request .
In my windows ANSICON console, it works. so, I merged it.

Can you check that is able to show color in your environment ?

@Praful
Copy link
Author

Praful commented May 15, 2014

Yes, I can see colours now in the Windows command prompt and ConEmu! Many thanks @monochromegane and @shiena.

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

Successfully merging a pull request may close this issue.

2 participants