Skip to content

Soleronline/show_git_branch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Show git branch in at the prompt

Show the name of the branch you are in at the prompt

  1. Open your terminal

  2. Edit the .bashrc file

user@mypc:~$ vim ~/.bashrc
  1. At the end of the file add the following lines:
show_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h:\[\033[32m\]\w\[\033[36m\]\$(show_git_branch)\[\033[00m\]$ "
  1. Save the file

  2. Redirect to a directory where you have a repository and you will see the changes

user@mypc:~$ cd apps/show_git_branch
user@mypc:~/apps/show_git_branch (main)$ 

About

Show the name of the branch you are in at the prompt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors