Skip to content

Instantly share code, notes, and snippets.

@nsommer
Created April 29, 2018 16:05
Show Gist options
  • Save nsommer/28c97608b8f61527edccddc2b57aef4d to your computer and use it in GitHub Desktop.
Save nsommer/28c97608b8f61527edccddc2b57aef4d to your computer and use it in GitHub Desktop.
Bash prompt that displays current git branch and directory
# Get the Git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Custom bash prompt
#
# Includes custom character for the prompt, path, and Git branch name.
#
# Source: kirsle.net/wizards/ps1.html
export PS1="\[$(tput setaf 6)\]\w\[$(tput setaf 3)\]\$(parse_git_branch) \[$(tput sgr0)\]\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment