Sha256: c215f352b6b9105e0947ff033f05f75e39e173857ff30aef5bdd1d23d4474711

Contents?: true

Size: 1.34 KB

Versions: 21

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env bash

add(){
  token="$1"
  eval "${token}_flag=1" ; shift
  if [[ ! -z "$format" ]] ; then
    format="${format}-\$${token}"
  else
    format="\$${token}"
  fi
}

if [[ ! -z "$(which ruby 2>/dev/null | 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" ;;
      *) echo "Unrecognized command line option '$token' for $0" ; exit 1 ;;
    esac
  done

  if [[ -z "$format" ]] ; then
    add "interpreter"
    add "version"
    add "patchlevel"
  fi

  ruby_string=$(dirname "$(which ruby 2>/dev/null)" | xargs dirname | xargs basename)
  if [[ ! -z "$interpreter_flag" ]] ; then
    interpreter="$(echo $ruby_string | awk -F'-' '{print $1}')"
  fi
  if [[ ! -z "$version_flag" ]] ; then
    version="$(echo $ruby_string | awk -F'-' '{print $2}')"
  fi
  if [[ ! -z "$patchlevel_flag" ]] ; then
    patchlevel=$(echo $ruby_string | awk -F'-' '{print $3}')
  fi
  if [[ ! -z "$architecture_flag" ]] ; then
    architecture="$(echo "$(ruby -v)" | sed 's/^.*\[//' | sed 's/\].*$//')"
  fi

  command="prompt=\"$format\""
  eval "$command"
  echo "${prompt/-]/]}"
fi

exit 0

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rvm-0.1.23 binscripts/rvm-prompt
rvm-0.1.22 binscripts/rvm-prompt
rvm-0.1.21 binscripts/rvm-prompt
rvm-0.1.20 binscripts/rvm-prompt
rvm-0.1.19 binscripts/rvm-prompt
rvm-0.1.18 binscripts/rvm-prompt
rvm-0.1.16 binscripts/rvm-prompt
rvm-0.1.15 binscripts/rvm-prompt
rvm-0.1.14 binscripts/rvm-prompt
rvm-0.1.13 binscripts/rvm-prompt
rvm-0.1.12 binscripts/rvm-prompt
rvm-0.1.11 binscripts/rvm-prompt
rvm-0.1.10 binscripts/rvm-prompt
rvm-0.1.9 binscripts/rvm-prompt
rvm-0.1.8 binscripts/rvm-prompt
rvm-0.1.7 binscripts/rvm-prompt
rvm-0.1.6 binscripts/rvm-prompt
rvm-0.1.5 binscripts/rvm-prompt
rvm-0.1.3 binscripts/rvm-prompt
rvm-0.1.2 binscripts/rvm-prompt