1. Download the git-prompt.sh file from github using the curl command in the terminal window.
~ ? curl -Lo .git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
2. Add the following to your .bash_profile or .bashrc file:
This small script adds an if statement to check if the file exists, sets the source to .git-prompt.sh, and set the PS1 variable to point to the __git_ps1 function in the .git-prompt.sh file. The \e[1;32m and \e[m\ are color tags used to color the branch text.
When you navigate to a folder that contains a git repository you should see something like the following:
GitProjectFolder (Master) $ git checkout NewBranch
GitProjectFolder (NewBranch) $ ~ ? curl -Lo .git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
2. Add the following to your .bash_profile or .bashrc file:
if [ -f ~/.git-prompt.sh ]; then
source ~/.git-prompt.sh
export PS1='\W\e[1;32m$(__git_ps1 "(%s)")\e[m\$ '
fi This small script adds an if statement to check if the file exists, sets the source to .git-prompt.sh, and set the PS1 variable to point to the __git_ps1 function in the .git-prompt.sh file. The \e[1;32m and \e[m\ are color tags used to color the branch text.
When you navigate to a folder that contains a git repository you should see something like the following:
GitProjectFolder (Master) $ git checkout NewBranch
Links
Change the Terminal Command Prompt
Customizing the Color of Your Terminal Prompt
No comments:
Post a Comment