Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 1.0.2
Fetching contributors…

Cannot retrieve contributors at this time

executable file 107 lines (91 sloc) 2.949 kb
#!/usr/bin/env bash
add(){
token="$1"
eval "${token}_flag=1" ; shift
if [[ ! -z "$format" ]] ; then
format="${format}-\$${token}"
else
format="\$${token}"
fi
}
rvm_gemset_separator="${rvm_gemset_separator:-"@"}"
ruby=$(command -v ruby)
if [[ ! -z "$ruby" ]] && [[ ! -z "$(echo "$ruby" | awk '/rvm/{print}')" ]] ; then
unset format
while [[ $# -gt 0 ]] ; do
token="$1" ; shift
case "$token" in
i|interpreter) add "interpreter" ;;
v|version) add "version" ;;
p|patchlevel) add "patchlevel" ;;
r|revision) add "revision" ;;
a|architecture) add "architecture" ;;
g|gemset) add "gemset" ;;
u|unicode) add "unicode" ;;
s|system) add "system" ;;
-d|--no-default) no_default=1 ;;
*) echo "Unrecognized command line option '$token' for $0" ; exit 1 ;;
esac
done
if [[ -z "$format" ]] ; then
add "interpreter"
add "version"
add "patchlevel"
add "gemset"
fi
ruby_string=$(dirname "$ruby" | xargs dirname | xargs basename)
# Dont' display anything if no default flag was provided and we're using the default ruby
if [[ -n "$no_default" && "$(rvm tools identifier)" = "$(rvm alias show default)" ]]; then
exit 0
fi
if [[ -n "$interpreter_flag" ]] || [[ ! -z "$unicode_flag" ]] ; then
interpreter="${ruby_string/-*/}"
fi
if [[ -n "$version_flag" ]] || [[ ! -z "$unicode_flag" ]] ; then
version="${ruby_string%-*}" ; version="${version#*-}"
fi
if [[ -n "$patchlevel_flag" ]] ; then
patchlevel="${ruby_string##*-}"
fi
if [[ -n "$architecture_flag" ]] ; then
architecture="$(echo "$(ruby -v)" | sed 's/^.*\[//' | sed 's/\].*$//')"
fi
if [[ -n "$gemset_flag" && "$GEM_HOME" =~ ${rvm_gemset_separator} ]] ; then
gemset="${rvm_gemset_separator}${GEM_HOME/*${rvm_gemset_separator}/}"
fi
if [[ -n "$unicode_flag" ]] ; then
case "$interpreter" in
jruby) unicode="" ;;
rbx) unicode="" ;;
ree) unicode="" ;;
macruby) unicode="" ;;
maglev) unicode="" ;;
ironruby) unicode="" ;;
mput) unicode="" ;;
system) unicode="" ;;
ruby)
case "$version" in
1.8.6) unicode="" ;;
1.8.7) unicode="" ;;
1.9.1) unicode="" ;;
1.9.2) unicode="" ;;
*) unicode="" ;;
esac ;;
*) unicode="" ;;
esac
if echo "$ruby_string" | \grep -q '-head' ; then
unicode="${unicode}"
fi
fi
command="prompt=\"$format\""
eval "$command"
echo "$prompt" | sed -e 's#^[[:space:]]*-*##g' -e 's#--*#-#g' -e 's#-*[[:space:]]*$##' -e 's#-'${rvm_gemset_separator}'#'${rvm_gemset_separator}'#'
else
while [[ $# -gt 0 ]] ; do
token="$1" ; shift
case "$token" in
s|system) echo "system" ;;
esac
done
fi
exit 0
Jump to Line
Something went wrong with that request. Please try again.