Skip to content

Instantly share code, notes, and snippets.

@arion
Created March 7, 2012 04:57
Show Gist options
  • Save arion/1991018 to your computer and use it in GitHub Desktop.
Save arion/1991018 to your computer and use it in GitHub Desktop.
Show rvm gemset ans git branch in your command prompt
function detect_git_branch {
local git_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/")
[ "$git_branch" != "" ] && echo " ($git_branch) "
}
function detect_rvm_name {
local gemset=$(echo $GEM_HOME | awk -F'/' '{print $NF}')
[ "$gemset" != "" ] && echo "($gemset)"
}
function dev_info {
echo "$(detect_rvm_name)$(detect_git_branch)"
}
# Colors
txtred='\e[0;31m' # Red
txtwht='\e[0;37m' # White
txtrst='\e[0m' # Text Reset
# Custom command prompt
export PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \[$txtwht\]\w \[$txtred\]\$(dev_info)\[$txtwht\]$
\[$txtrst\]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment