DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Gnu grep how can I get colored output in ms concole?  (Read 10,203 times)

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
Gnu grep how can I get colored output in ms concole?
« on: May 16, 2009, 01:13 AM »
I cannot seem to get colored output from Gnu Grep. I tried the color option maybe standard ms console does not support such thing. Does anyone know a solution?

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Gnu grep how can I get colored output in ms concole?
« Reply #1 on: May 16, 2009, 11:20 PM »
Seems ansi.sys isn't installed on Vista.  You may have to run bash shell and use --color option on the grep command. I know I had ls output with color so there must be a way to do it.  It's been a few years though. There should be a way to set up an alias in bash so that the --color param is appended automatically.  Something like:  grep=grep --color  and ls=ls --color  plus whatever other default params you want to stick on.

See bash win32 docs for alias commands



« Last Edit: May 16, 2009, 11:43 PM by MilesAhead »

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 3,217
Re: Gnu grep how can I get colored output in ms concole?
« Reply #2 on: May 17, 2009, 09:26 PM »
You could try third-party Windows-ised ANSI programs, like the ones by Jason Hood, or ANSIPlus by Kris Sweger.

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
Re: Gnu grep how can I get colored output in ms concole?
« Reply #3 on: May 18, 2009, 02:44 AM »
Thanks people, I will check out these stuff.

f0dder

  • [Well, THAT escalated quickly!]
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
    • Participated in NANY Challenge Once
Re: Gnu grep how can I get colored output in ms concole?
« Reply #4 on: May 18, 2009, 06:03 AM »
Being a DOS application/device driver, ANSIPLUS doesn't sound like something that'll work (properly) with NT-based operating systems?
- carpe noctem

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 3,217
Re: Gnu grep how can I get colored output in ms concole?
« Reply #5 on: May 18, 2009, 12:59 PM »
Being a DOS application/device driver, ANSIPLUS doesn't sound like something that'll work (properly) with NT-based operating systems?

ANSIPLUS and Windows
Quote
Users of Windows 98, 95, 3.1 or NT 4 should consider using ANSIPLUS as well. The ANSIPLUS driver works well under Windows, and because ANSIPLUS is a CON device driver, local copies of it are included in each Windows virtual DOS machine. This means that all the ANSIPLUS internal state variables, and those of its integrated console features, will be local to each virtual machine, so there is no way they can interfere with each other. This section discusses how to work around the specific limitations imposed on ANSIPLUS DOS sessions by Windows or by Windows in combination with other software.

The following topics are covered here: Loading options, Full screen vs. windowed DOS sessions, Copy and paste, Scroll-back, Color palettes, Beep tone, International usage, and Windows NT.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Gnu grep how can I get colored output in ms concole?
« Reply #6 on: May 19, 2009, 01:29 AM »
Being a DOS application/device driver, ANSIPLUS doesn't sound like something that'll work (properly) with NT-based operating systems?
Being a DOS application/device driver, ANSIPLUS doesn't sound like something that'll work (properly) with NT-based operating systems?

'sides, I'm fairly certain if you use Win32 Gnu bash stuff all that Linux color output will work.  It's not that big a deal to set it up. It's just it's been a couple of years so I'm not sure which LinuxOnWindows type site is the one to go with.  My memory lags. :)

f0dder

  • [Well, THAT escalated quickly!]
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
    • Participated in NANY Challenge Once
Re: Gnu grep how can I get colored output in ms concole?
« Reply #7 on: May 19, 2009, 01:23 PM »
rjbull: I only have 64bit installs of Windows atm, so I can't test it - but my guess is that for NT it's only going to affect the current (ie, not all cmd.exe instances), and either won't work for win32 console applications or is going to slow down console output tremendously - will probably work for 16bit dos applications, but possibly also involving slowdown.

Anyway, the best option would be getting tools that natively support the win32 console API (or a shell that supports ANSI colors...), instead of resorting to hacks. Too bad the UnxUtils project is dead, so you're probably stuck with the cygwin (bleargh!) based gnuwin32 :(
- carpe noctem

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Gnu grep how can I get colored output in ms concole?
« Reply #8 on: May 19, 2009, 02:52 PM »
I cannot seem to get colored output from Gnu Grep. I tried the color option maybe standard ms console does not support such thing. Does anyone know a solution?

Depending what you are doing, you may find this useful:

http://betterthangrep.com/

Original address: https://www.donationcoder.com/forum/index.php?topic=18335.0