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?
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?
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!
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.