I have this command:
git stash list --pretty="%C(yellow)%h %>(14)%Cgreen%cr %C(blue)%gs"
gives output colored, but if I pipe it
git stash list <..> | less -R, color disappear in output.
How to persist color of
git stash list via pipe?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
This is a feature, because git doesn't know what you are piping to.
You can configure the command to always output colors like this:
git -c color.ui=always your command | less -R
-c <name>=<value> Pass a configuration parameter to the command. The value given will override values from configuration files. The <name> is expected in the same format as listed by git config (subkeys separated by dots).
Another option is to configure
git config core.pager "less -R"
So you don't need to pipe to