Sha256: e62fc6be1e90022476250d3d3953528ecb58f03275d5356f95846acd9a17b6ab

Contents?: true

Size: 1.34 KB

Versions: 13

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

13 entries across 13 versions & 1 rubygems

Version Path
rvm-0.0.96 binscripts/rvm-prompt
rvm-0.0.95 binscripts/rvm-prompt
rvm-0.0.93 binscripts/rvm-prompt
rvm-0.0.92 binscripts/rvm-prompt
rvm-0.0.91 binscripts/rvm-prompt
rvm-0.0.90 binscripts/rvm-prompt
rvm-0.0.89 binscripts/rvm-prompt
rvm-0.0.88 binscripts/rvm-prompt
rvm-0.0.87 binscripts/rvm-prompt
rvm-0.0.86 binscripts/rvm-prompt
rvm-0.0.85 binscripts/rvm-prompt
rvm-0.0.84 binscripts/rvm-prompt
rvm-0.0.83 binscripts/rvm-prompt