我想为git diff --name-status
设置bash输出的样式,以便状态为D
,M
和A
的文件具有不同的颜色。如何通过文件状态添加颜色到'git diff --name-status`的bash输出中?
风格一般的git bash我使用.gitconfig
中的color
选项。
# .gitconfig
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
款式像git log
一个命令的输出,我可以在一个别名使用--pretty=format
象下面这样:
# .gitconfig
[alias]
log = log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
不过,我已经使用了--pretty=format
git diff --name-status
是不成功的。
我想风格输出目前没有风格,看起来像:
$ git diff <branch> --name-status
M .gitignore
M README.md
A diagnostic.js
D diagnostic.md
有没有一种办法风格深受状态类型的输出git diff --name-status
?
我从来没有越过'git的差异--name-status'标志上色,但它看起来很像'git的状态 - 具有内置颜色的“短”。这会对你有用吗? –