WhatSize in Bash V2 Oct 7th, 2011 | Comments Screenshots: Source: #!/usr/bin/env bash # Thanks to bolk http://bolknote.ru/2011/09/14/~3407#07 function PrintBar { if [[ $TERM =~ 256 || $TERM_PROGRAM = "iTerm.app" ]]; then local colors=("38;5;34" "38;5;220" "38;5;160") else local colors=(32 33 31) fi local c=${colors[0]} [ $1 -ge 13 ] && c=${colors[1]} [ $1 -ge 20 ] && c=${colors[2]} local bar=$(cat) local prg=$(printf "%0$1s" | tr 0 ${bar:2:1}) local rep="\033[${c}m$prg\033[30m" echo -e ${bar/$prg/$rep} } function PrintItems { du -s * | sort -rn | head -n $listlength \ | sed s/^[0-9]*// | while read item do if [ "$item" != "" ]; then local cur=$(du -s "$item" | awk '{ print $1 }' ) [[ $max = "" ]] && max=$cur let percent="($cur*40/$max)" folder=`du -hs "$item"` echo -e "│ ████████████████████████████████████████ \033[0m│ $folder" \ | PrintBar $percent fi done } if [ "$1" = "" ]; then listlength=10 else listlength=$1 fi echo ┌──────────────────────────────────────────┐ PrintItems echo └──────────────────────────────────────────┘ echo -e "\033[0m" Thanks to bolk