Skip to content

Instantly share code, notes, and snippets.

@nzakas
Created July 13, 2011 23:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nzakas/1081567 to your computer and use it in GitHub Desktop.
Save nzakas/1081567 to your computer and use it in GitHub Desktop.
Dead simple branch-in-prompt for Git
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\w\$(parse_git_branch) $ "
@valueof
Copy link

valueof commented Jul 14, 2011

Have you tried git-sh?

@nzakas
Copy link
Author

nzakas commented Jul 14, 2011

I haven't. All I really wanted was the branch name in the prompt.

@valueof
Copy link

valueof commented Jul 14, 2011

Yeah, I don't use all features of git-sh but autocompletion and dirty-working-dir indicator is nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment