Sha256: 5d2a87fbc20c4ee40c3d6276158c1c0a5cb96c07e0cec034c5140e7197798818

Contents?: true

Size: 1.31 KB

Versions: 14

Compression:

Stored size: 1.31 KB

Contents

#!/bin/bash

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

if [[ ! -z "$(which 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" ;;
      *) 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)" | 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

14 entries across 14 versions & 1 rubygems

Version Path
rvm-0.0.76 binscripts/rvm-prompt
rvm-0.0.75 binscripts/rvm-prompt
rvm-0.0.74 scripts/rvm-prompt
rvm-0.0.73 scripts/rvm-prompt
rvm-0.0.72 scripts/rvm-prompt
rvm-0.0.71 scripts/rvm-prompt
rvm-0.0.70 scripts/rvm-prompt
rvm-0.0.69 scripts/rvm-prompt
rvm-0.0.68 scripts/rvm-prompt
rvm-0.0.67 scripts/rvm-prompt
rvm-0.0.66 scripts/rvm-prompt
rvm-0.0.65 scripts/rvm-prompt
rvm-0.0.64 scripts/rvm-prompt
rvm-0.0.63 scripts/rvm-prompt