Git漂亮的格式颜色 [英] Git pretty format colors

查看:700
本文介绍了Git漂亮的格式颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Git设置漂亮的格式颜色。从我可以告诉的版本1.6.0只识别红色,绿色和蓝色。

  $ git log --pretty = format: %Credred%Creset%Cgreengreen%Creset%Cyellowyellow%Creset%Cblueblue%Creset%Cmagentamagenta%Creset%Ccyancyan%Creset%Cwhitewhite%Creset
红色绿色%Cyellowyellow%Creset蓝色%Cmagentamagenta%Ccyancyan%Cwhitewhite

此外,没有任何颜色使用圆括号的颜色格式。



有没有办法列出Git可用的漂亮格式颜色?



不幸的是,这是在传统的SCO OpenServer 5.0上。 7机器和由SCO Skunkworks发布的Git的最新版本为1.6.0.3。

我没有旧版本的 git 来验证除 red以外的颜色, blue 并支持 green



尽管我注意到最近版本的 git (比如我使用的1.7.10)是 red green code>和 blue 需要位于括号内()。对于绿,括号是可选的。

所以试试这个:

  git log  - 漂亮=格式:%红色%Creset%Cgreengreen%Creset%C(黄色)黄色%Creset%Cblueblue%Creset%C(洋红色)洋红色%Creset%C(青色)青色%Creset%C(白色)白色%Creset 

我知道的颜色列表至少包括:

 正常
黑色
红色
绿色
黄色
蓝色
洋红色
青色
白色

可以结合以下属性之一:

 加粗
dim
ul
眨眼
反转

如果您尝试使用 .gitconfig 更改颜色,您应该能够指定两种颜色 - 前景背景,您可以将其与一个属性组合。


I'm trying to set up pretty format colors for Git. From what I can tell version 1.6.0 only recognizes red, green and blue.

$ git log --pretty=format:"%Credred%Creset %Cgreengreen%Creset %Cyellowyellow%Creset %Cblueblue%Creset %Cmagentamagenta%Creset %Ccyancyan%Creset %Cwhitewhite%Creset"
red green %Cyellowyellow%Creset blue %Cmagentamagenta %Ccyancyan %Cwhitewhite

In addition none of the colors work with the parenthesized color format.

Is there a way to list the available pretty format colors for Git?

Unfortunately this is on a legacy SCO OpenServer 5.0.7 machine and the last version of Git released by SCO Skunkworks was 1.6.0.3.

解决方案

I do not have an old version of git to verify that the colors other than red, blue and green are supported.

Although, one thing I noticed even with the recent versions of git (like 1.7.10 I used) is that colors other than red, green and blue need to be within parentheses (). For red, green and blue, the parentheses are optional.

So give this a try:

git log --pretty=format:"%Credred%Creset %Cgreengreen%Creset %C(Yellow)yellow%Creset %Cblueblue%Creset %C(magenta)magenta%Creset %C(cyan)cyan%Creset %C(white)white%Creset"

The list of colors I'm aware of at least are:

normal
black
red
green
yellow
blue
magenta
cyan
white

It can be combined with one of these attributes:

bold
dim
ul
blink
reverse

If you're trying to change colors using .gitconfig you should be able to specify two colors - foreground and background and you can combine it with an attribute.

这篇关于Git漂亮的格式颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆