Skip to content

Instantly share code, notes, and snippets.

@heiberg
Created January 3, 2012 11:50
Show Gist options
  • Save heiberg/1554622 to your computer and use it in GitHub Desktop.
Save heiberg/1554622 to your computer and use it in GitHub Desktop.
Bash prompt with Git branch info
# Evaluate my local copy of
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# which also provides TAB-completion of git sub-commands, branches etc.
source ~/Dropbox/Config\ Files/dotfiles/git-completion.bash
function set_prompt {
# Black 0;30 Dark Gray 1;30
# Blue 0;34 Light Blue 1;34
# Green 0;32 Light Green 1;32
# Cyan 0;36 Light Cyan 1;36
# Red 0;31 Light Red 1;31
# Purple 0;35 Light Purple 1;35
# Brown 0;33 Yellow 1;33
# Light Gray 0;37 White 1;37
local BLACK="\[\033[0;30m\]"
local RED="\[\033[0;31m\]"
local GREEN="\[\033[0;32m\]"
local YELLOW="\[\033[0;33m\]"
local BLUE="\[\033[0;34m\]"
local MAGENTA="\[\033[0;35m\]"
local CYAN="\[\033[0;36m\]"
local WHITE="\[\033[0;37m\]"
local BRIGHT_BLACK="\[\033[1;30m\]"
local BRIGHT_RED="\[\033[1;31m\]"
local BRIGHT_GREEN="\[\033[1;32m\]"
local BRIGHT_YELLOW="\[\033[1;33m\]"
local BRIGHT_BLUE="\[\033[1;34m\]"
local BRIGHT_MAGENTA="\[\033[1;35m\]"
local BRIGHT_CYAN="\[\033[1;36m\]"
local BRIGHT_WHITE="\[\033[1;37m\]"
# Can't be local.
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM=
PS1="$BRIGHT_GREEN\w$YELLOW\$(__git_ps1 ' (%s)')\n$BRIGHT_MAGENTA[\!]$WHITE\$ "
PS2='> '
PS4='+ '
}
set_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment