/ Published in: Bash
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
# ~/.profile
function detect_rvm_version {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
[ "$version" != "" ] && version="$version"
local full="$version$gemset"
[ "$full" != "" ] && echo "$full"
}
function detect_git_dirty {
local git_status=$(git status 2>&1 | tail -n1)
[[ $git_status != "fatal: Not a git repository (or any of the parent directories): .git" ]] && [[ $git_status != "nothing to commit (working directory clean)" ]] && echo "*"
}
function detect_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
}
function dev_info {
echo "[$(detect_rvm_version) $(detect_git_branch)$(detect_git_dirty)]"
}
# Colors
txtred='\e[0;31m' # Red
txtwht='\e[0;37m' # White
txtrst='\e[0m' # Text Reset
# Custom command prompt
export PS1="\[$txtwht\]\w \[$txtred\]\$(dev_info) \[$txtrst\]"
# If you don't have colors, use something like this instead:
# export PS1="\w \$(dev_info) "
Comments
 Subscribe to comments
                    Subscribe to comments
                
                