Created
March 7, 2012 04:57
-
-
Save arion/1991018 to your computer and use it in GitHub Desktop.
Show rvm gemset ans git branch in your command prompt
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
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