Is there a way to color output for git (or any command)?
Consider:
baller@Laptop:~/rails/spunky-monkey$ git status
# On branch new-message-types
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: app/models/message_type.rb
#
no changes added to commit (use "git add" and/or "git commit -a")
baller@Laptop:~/rails/spunky-monkey$ git add app/models
And
baller@Laptop:~/rails/spunky-monkey$ git status
# On branch new-message-types
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: app/models/message_type.rb
#
The output looks the same, but the information is totally different: the file has gone from unstaged to staged for commit.
Is there a way to colorize the output? For example, files that are unstaged are red, staged are green?
Or even Changes not staged for commit:
to red and # Changes to be committed:
to green?
Working in Ubuntu.
EDIT: Googling found this answer which works great: git config --global --add color.ui true
.
However, is there any more general solution for adding color to a command output?
Best Answer
You can create a section
[color]
in your~/.gitconfig
with e.g. the following contentYou can also fine control what you want to have coloured in what way, e.g.
I hope this gets you started. And of course, you need a terminal which supports colour.