Created
July 28, 2010 09:25
-
-
Save cppforlife/493849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COLOR_RED="\[\e[31;40m\]" | |
COLOR_GREEN="\[\e[32;40m\]" | |
COLOR_CYAN="\[\e[36;40m\]" | |
COLOR_RESET="\[\e[0m\]" | |
function git_branch_name { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo " ("${ref#refs/heads/}")" | |
# possible to use __git_ps1 here | |
} | |
function git_branch_color { | |
if [[ $(git status 2> /dev/null | grep -c :) == 0 ]] | |
then echo "${COLOR_GREEN}" | |
else echo "${COLOR_RED}" | |
fi | |
} | |
function rvm_current_env { | |
if [[ $(gem env gemdir) =~ \.rvm/gems/(.*) ]] | |
then echo " (${BASH_REMATCH[1]})" | |
fi | |
} | |
function prompt_title { | |
PS1="\w${COLOR_CYAN}$(rvm_current_env)$(git_branch_color)$(git_branch_name)${COLOR_RESET} \$ " | |
} | |
PROMPT_COMMAND=prompt_title |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment