I would like to style the bash output for git diff --name-status so that the files with status D, M, and A are different colors.
To style general git bash I use the color options in .gitconfig.
# .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
To style an output for a command like git log I can use --pretty=format in an alias like below:
# .gitconfig
[alias]
log = log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
However, I have been unsuccessful using --pretty=format for git diff --name-status.
The output I would like to style is currently not styled and looks like:
$ git diff <branch> --name-status
M .gitignore
M README.md
A diagnostic.js
D diagnostic.md
Is there a way to style the output git diff --name-status by status type?
git diff --name-statusflag, but it looks a lot likegit status --shortwhich has built-in colors. Would that do the trick for you?git statusto show a specific commit.git status --shortis great though; this is exactly what I'd want to see from a colorized--name-statusoption