Created
September 11, 2013 19:29
-
-
Save mzaragoza/6528597 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can add the following code to you .bashrc file: | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$(parse_git_branch) $ " | |
You can move around these component parts to configure to your tastes, for example to prepend $(parse_git_branch) and not show the user@computer part I used: | |
PS1="\$(parse_git_branch)${debian_chroot:+($debian_chroot)}\w$ " | |
Which displays: | |
(master)~/my_projects/project_x$ | |
See also: What is this PS1 variable doing in .bash_profile file? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/18749653/prepend-current-git-branch-in-terminal