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:
- You are using bash as your login shell
- Currently Mac uses zsh as the default login shell and you may have to change it bash for the following script to work
- 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.