Show Git Branch in Command Prompt (Ubuntu)

Jan 27, 2019
Using git-prompt.sh

Download git-prompt.sh

cd ~wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O .git-prompt.sh

Edit .bashrc

nano ~/.bashrc

Add the following at the end of the file

source ~/.git-prompt.shPS1='[\u@\h:\w$(__git_ps1 " (%s)")]\$ '

NOTE: You can customize the bash prompt/PS1.

Start a new command prompt or run

source .bashrc

NOTE: You might want to look into bash-git-prompt for a more fancy bash prompt for git.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.