Skip to content

Instantly share code, notes, and snippets.

@Oshuma
Created October 11, 2009 01:31
Show Gist options
  • Save Oshuma/207311 to your computer and use it in GitHub Desktop.
Save Oshuma/207311 to your computer and use it in GitHub Desktop.
rvm-prompt.zsh
# zsh functions to grab the current ruby version info from RVM.
# Useful mainly in prompts (see http://skitch.com/oshuma/nni3k/zsh-prompt-git-clean).
# ~/.zshrc
# RPS1=$'Ruby v$(ruby_prompt_version)'
# Ruby Version Manager
if [ -s ~/.rvm/scripts/rvm ] ; then
source ~/.rvm/scripts/rvm
# Prompt function. Return the full version string.
function ruby_prompt_version_full {
version=$(
rvm info |
grep -m 1 'full_version' |
sed 's/^.*full_version:[ ]*//' |
sed 's/["]//g'
) || return
echo $version
}
# Prompt function. Return just the version number.
function ruby_prompt_version {
version=$(
rvm info |
grep -m 1 'version' |
sed 's/^.*version:[ ]*//' |
sed 's/["]//g'
) || return
echo $version
}
fi # Ruby Version Manager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment