Skip to content

Instantly share code, notes, and snippets.

@jeremyBanks
Created September 18, 2008 00:25
Show Gist options
  • Save jeremyBanks/11339 to your computer and use it in GitHub Desktop.
Save jeremyBanks/11339 to your computer and use it in GitHub Desktop.
[2010-01] an old (shitty?) PS1 I had. you should probably use the built-in one, now that it has it
export PS1="\W\$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ # \1/' -e \"s/(no branch)/\$(git rev-parse --short HEAD 2> /dev/null)…/\") \$ "
This requires a call to git-branch and to git-rev-parse for every shell
prompt to be displayed. This did not result in a noticeable delay for
me, your milage may vary. If we're in a git repository it adds a hash
sign and the name of the current branch to the prompt. If we're not at
the head of the branch, it displays the short form of the HEAD's SHA.
~ $ cd src
src $ cd blog
blog # master $ g co HEAD~
blog # 5eee687… $ g co HEAD~
blog # 8af5aec… $ g co master
blog # master $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment