Sha256: f79351d3bf6545f676749d216ddb381bcd46694587b7aba41e4e7375ed2c2c56

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

#!/usr/bin/env bash

#!/usr/bin/env bash
rvm_base_except="selector"
source "$rvm_scripts_path/base"

usage() {
  printf "Usage: 'rvm disk-usage {all,archives,repos,sources,logs,packages}'\n"
  printf "       Lists the space rvm uses for a given item.\n"
  exit 1
}

disk_usage_for_directory() {
  du -hs "$1" | awk '{print $1}'
}

disk_usage() {
  eval "local current_path=\"\$rvm_${2}_path\""
  if [[ -n "$current_path" && -d "$current_path" && "$current_path" != "/" ]]; then
    echo "$1 Usage: $(disk_usage_for_directory "$current_path")"
  fi
  unset current_path
}

all_disk_usage() {
  archives_disk_usage
  repos_disk_usage
  sources_disk_usage
  logs_disk_usage
  packages_disk_usage
  total_disk_usage
}

total_disk_usage() {
  echo "Total Disk Usage: $(disk_usage_for_directory "$rvm_path")"
}

archives_disk_usage() { disk_usage "Downloaded Archives" "archives"; }
repos_disk_usage()    { disk_usage "Repositories" "repo"; }
sources_disk_usage()  { disk_usage "Extracted Source Code" "src"; }
logs_disk_usage()     { disk_usage "Log Files" "log"; }
packages_disk_usage() { disk_usage "Packages" "usr"; }


# Exit when there is no argument.
[[ -z "$1" ]] && usage

case "$1" in
  all|archives|repos|sources|logs|total|packages) eval "$1_disk_usage" ;;
  *)        usage ;;
esac

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rvm-1.0.0 scripts/disk-usage
rvm-0.1.47 scripts/disk-usage
rvm-0.1.46 scripts/disk-usage
rvm-0.1.45 scripts/disk-usage
rvm-0.1.44 scripts/disk-usage
rvm-0.1.43 scripts/disk-usage