Skip to content

Instantly share code, notes, and snippets.

@mnem
Created September 20, 2010 22:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mnem/588800 to your computer and use it in GitHub Desktop.
Save mnem/588800 to your computer and use it in GitHub Desktop.
Prettifies bash terminals with git
# Setup the prompt so that it shows the current branch when in a git directory.
source /usr/local/etc/bash_completion.d/git-completion.bash
source /usr/local/etc/bash_completion.d/git-prompt.sh
function setup_prompts_for_git
{
local BLUE="\[\e[0;34m\]"
local RED="\[\e[0;31m\]"
local YELLOW="\[\e[0;33m\]"
local PURPLE="\[\e[0;35m\]"
local CLR_RESET="\[\e[0m\]"
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}$BLUE[$RED\$(date +%H:%M)$BLUE][$RED\u@\h:$PURPLE\w$YELLOW\$(__git_ps1)$BLUE]$CLR_RESET\n\$ "
PS2='> '
PS4='+ '
}
setup_prompts_for_git
@mnem
Copy link
Author

mnem commented Sep 20, 2010

Show git branch in shell prompt

Plop this at the end of your ~/.profile or ~/.bash_profile file to make your prompt vibrant and also display the current git branch you are working in.

Preview

Vibrant Paths

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