Revision: 28267
Updated Code
at July 6, 2010 05:19 by harrikauhanen
Updated Code
# ~/.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) "
Revision: 28266
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 6, 2010 05:15 by harrikauhanen
Initial Code
# ~/.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)]"
}
# Ruby Version Manager
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
# Show colors in less
export LESS="-R"
# 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\]"
Initial URL
Initial Description
Initial Title
Show rvm gemset, git branch and git status in your command prompt
Initial Tags
Initial Language
Bash