How to get informative, color prompts on Mac Terminal or iTerm2

How to get informative, color prompts on Mac Terminal or iTerm2

This article talks about how to get color prompts on your terminal and add some informative things like current git branch and distinctive colors for current path, username etc.
Software Development
by Jey Geethan | August 14, 2019

The default prompts on the terminal and iTerm2 are good but are not very descriptive and useful. I wanted to create a prompt that shows the following:

  • Current path
  • Current git branch (if within a git repo)
  • Username
  • All the above in very distinctive colors

This is important so that I instinctively know where I am, what I am doing. Also I do not want to commit to the wrong branch. Sometimes I keep working in a wrong branch to figure out a bug only until later to know that the branch was wrong. So I wanted to know the branch on my terminal all the time. I scripted the following to solve all these problems.

Notes:

  1. You are using bash as your login shell
  2. Currently Mac uses zsh as the default login shell and you may have to change it bash for the following script to work
  3. Source the script file for the first time use

All you have to do is to use the following script in your ~/.bash_profile

Gist link: https://gist.github.com/jeygeethan/a6d261d32cea97e9a52b82f48989c07f

Happy development!

If you like my content, be sure to like and leave a comment.


Jey Geethan

Jey Geethan is a poet, author and an entrepreneur.


Related Articles

Software Development

Top 5 Tips for Software Development Managers To Conduct Effective 1 on 1s With Your Reports

by Jey Geethan | October 05, 2020
Top 5 Tips for Software Development Managers To Conduct Effective 1 on 1s With Your Reports
Some of the effective tips that can enhance your 1 on 1s with your reports. In 2020, software development is one of the major industries which provides millions of jobs. In fact, if you look at the statistics, this industry is poised to grow even further. According to Slashdata, it's expected to reach 45 million developers by 2030. As a manager, it's your responsibility that 1 on 1s are effective and help your reports. I want to talk about a few of the things that make this process really effective.
Software Development

Show full file path in the title bar of Sublime and VS Code

by Jey Geethan | March 22, 2018
Show full file path in the title bar of Sublime and VS Code
If you feel that you want to show the full file paths in your favorite editors - Sublime Text and Visual Studio Code, follow the simple steps