Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Git bash prompt
This sorts out the problem of lines not wrapping properly.
export PS1='\[\e]0;\u@\h: \w\a\]\[\e[32;1m\]${debian_chroot:+($debian_chroot)}\u@\h:\w \[\e[33;1m\]$(__git_ps1 "[%s] ")\[\e[32;1m\]\$ \[\e[0m\]'
Copy exactly into your .bashrc. Note that __git_ps1 is a builtin (comes with git I assume) feature that provides the branch you are on if you are in a git area. There's no need for a separate function to obtain this information.
Read this page if interested about what all the funny, cryptic characters are all about:
(and to change the colours and background if you want to.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.