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