I'm working with Git, using Windows 7, PowerShell, and Posh-Git. I have the following alias setup:
ls = log --pretty=tformat:"%C(yellow)%h\\ %C(green)[%ad]%C(cyan)\\ <%cn>\\ %C(reset)%s%C(auto)%d"
The problem was that when I pipe the output to clip.exe to copy it to the clipboard, it also copies some characters for the colors. A little reading and I found you could add "auto," so that it would use the default colors if the --no-color
option is specified. So now I have:
ls = log --pretty=tformat:"%C(auto,yellow)%h\\ %C(auto,green)[%ad]%C(auto,cyan)\\ <%cn>\\ %C(auto,reset)%s%C(auto)%d"
The problem I now have is the last bit of the output showing the refs. I have the color set to auto so that git will apply the default colors for branches and tags, but can't figure out how to get it to respect the --no-color
option. If I set it to %C(auto) the colors show all the time. I tried %C(auto,auto) and that works with --no-color
, but without it git complains:
error: invalid color value: auto
fatal: unable to parse --pretty format
This will be fixed in git 2.9.x+ (Q3 2016)
See commit b15a3e0 (27 May 2016) by Edward Thomson (
ethomson
).(Merged by Junio C Hamano --
gitster
-- in commit 1b3d14c, 20 Jun 2016)This is what you see with git-for-windows 2.9.0
But with a more recent 2.9.x+ git version,
--no-color
does work: