Working with Git in the terminal can be hard to read and navigate at times. For the last year I have been forcing myself each day to use the terminal much more to get used to doing things without an interface. One pet peeve that I had was that my terminal text was always white on black and extremely hard to read. Then I stumbled across Cheat Sheets and figured out a way to get the terminal to work a little better for me.
Option 1: Edit the File
First, all the modifications that we’re making are to the
~/.gitconifg file located in your root user directory on Mac. In this file we will be adding the following lines of code.
[color] ui = auto [color "status"] added = green changed = yellow untracked = cyan
If you feel safer opening this file in your code editor of choice and adding the lines you can feel free to do that. Personally, I preferred to let the terminal do this work for me and thus turned to running a few terminal commands to add the lines of code that I needed.
Option 2: Using the Terminal
To turn on the default terminal coloring:
$ git config --global color.ui true
Git will now color the output it sends to the terminal. In my case all my terminal commands are “red” for modified and deleted files or “green” if they were added ready for commit.
You could stop here and probably be completely happy with everything, however, I wanted to take this a little step further and allow for a little more color variation in order to see what changes were being made in the terminal. In the code snippet above I have added a
color="status" section which fine tunes the color variations between the different statuses a file could be in during a Git commit. For example, untracked files I wanted to be “cyan” while my changed files were “yellow” rather than red (More of a personal preference rather than a general need).
Running the following three commands in the terminal will add the color options that I specified below.
$ git config --global color.status.added green $ git config --global color.status.changed yellow $ git config --global color.status.untracked cyan
Now when you run
git status you will see the following:
Hope that this helps with your journey with the terminal or an CLI type interface.
If you’re unfamiliar with Git or the Terminal please feel free to read these articles that show you the basics and what you can use them for.