Skip to content

Instantly share code, notes, and snippets.

@shyam-habarakada
Created March 20, 2012 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shyam-habarakada/2136713 to your computer and use it in GitHub Desktop.
Save shyam-habarakada/2136713 to your computer and use it in GitHub Desktop.
bash-rc-update.sh
function color_my_prompt {
local __user_and_host="\[\033[00;30m\]\u@digitalone"
local __cur_location="\[\033[00;31m\]\w"
local __git_branch_color="\[\033[32m\]"
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
local __prompt_tail="\[\033[35m\]$"
local __last_color="\[\033[00m\]"
export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color "
}
if [ "$color_prompt" = yes ]; then
color_my_prompt
fi
@shyam-habarakada
Copy link
Author

Add this to your .bashrc (or .bash_profile on OSX) to color your prompt and optionally show the current active git branch if you are inside a git repository. There is a bug where it gets a bit confused if you are in a detached submodule -- this isn't blocking us from using this at the moment.

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