Created
May 15, 2011 10:02
-
-
Save archan937/973016 to your computer and use it in GitHub Desktop.
Current RVM Ruby & Gemset and Git branch in your Bash prompt
This file contains hidden or 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
function current_rvm_ruby { | |
color=$(tput setaf 3) | |
default=$(tput sgr0) | |
version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') | |
gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') | |
[ "$gemset" != "" ] && gemset="@$gemset" | |
full=${color}${version}${gemset}${default} | |
[ "$full" != "" ] && echo "$full " | |
} | |
function current_git_branch { | |
red=$(tput setaf 1) | |
green=$(tput setaf 2) | |
default=$(tput sgr0) | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then | |
branch=$(git branch 2>/dev/null| sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/') | |
if git diff --quiet 2>/dev/null >&2 | |
then | |
branch=${green}$branch${default} | |
else | |
branch=${red}$branch${default} | |
fi | |
else | |
return 0 | |
fi | |
echo "$branch " | |
} | |
export PS1="\$(current_rvm_ruby)\u:\W \$(current_git_branch)$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment