Thanks to visit codestin.com
Credit goes to github.com

Skip to content

de-arl/git_ps1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

git_ps1

Tired of working in the wrong git branch by accident?

Place this function in your .bashrc:

    # Function to get current git branch  
    git_ps1()  
    {  
      GIT_BRANCH=$(git branch --show-current 2>/dev/null)  
      if [ "${GIT_BRANCH}" != '' ]; then echo "(${GIT_BRANCH}) "; fi  
    }  

Use it to set the PS1 variable which contains the prompt.

    # Prepend current git branch to bash prompt
    PS1="\[\033[01;31m\]\$(git_ps1)\[\e[0m\]${PS1}"

München Januar 2024, de-arl.

About

Show git branch in command line prompt

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages