Grep ruins color


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep ruins color
# 1  
Old 03-07-2009
Grep ruins color

When I run:

git branch -a

I git a nice green and red colored output, but if I pipe the above command through grep:

git branch -a | grep -v "master"

I lose my colored output. Is there a way around this?
# 2  
Old 03-08-2009
I guess that the "git" command is streaming a stack of terminal control characters to change colours on the screen as well as the real data output. By piping the output through grep, you'll potentially be stripping those characters out of the stream going to the terminal. Can't see an easy solution!Smilie
# 3  
Old 03-09-2009
neither pipe nor grep will explicitly strip them out, but its not difficult for a program to tell whether its output is a terminal or not and adjust accordingly.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to add 'color' in a grep?

Hello friends - I use various grep commands to search for data in a file. However, to add 'color' seems to not work. Is there a way to add color to two items that i search? so that i can easily identify in hundreds of lines of output what i am looking for? zegrep abcdefg... (7 Replies)
Discussion started by: DallasT
7 Replies

2. UNIX for Dummies Questions & Answers

color highlighting with 'more','grep' and 'vi'

Hi all, i would to find out how can i turn on color hightlighting with the 'more' command. When i view a big file, i tend to use the 'more' command and i would search for a interested string with the '/' command. Something the search returns more than 1 line found on the screen, how can i... (0 Replies)
Discussion started by: new2ss
0 Replies

3. Shell Programming and Scripting

tput smso (bold) ruins formatting

Hi, I have some very nicely formatted output on a monitor script and I'd like to make one of the fields bold when a threshold is reached but when I do it changes the formatting. I've tried using tabs to separate the fields and I've tried using printf to force the size of the fields. Below is... (2 Replies)
Discussion started by: pondlife
2 Replies
Login or Register to Ask a Question