#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG 7.8				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2009 Christopher Bratusek		#
#							#
#########################################################

white=$(bs-ng-echo $white)
orange=$(bs-ng-echo $orange)
iceblue=$(bs-ng-echo $iceblue)
green=$(bs-ng-echo $green)

_help ()
{

	echo -e "\n${white}Usage:\n"
	echo -e "${orange}showsize ${white}|${green} ! no options !\n"

}

_show_size ()
{

	let TotalBytes=0

	for Bytes in $(ls -lA -1 | grep "^-" | awk '{ print $5 }'); do
		let TotalBytes=$TotalBytes+$Bytes
	done

	if [ $TotalBytes -lt 1024 ]; then
		TotalSize=$(echo -e "scale=1 \n$TotalBytes \nquit" | bc)
		suffix="B"
	elif [ $TotalBytes -lt 1048576 ]; then
		TotalSize=$(echo -e "scale=1 \n$TotalBytes/1024 \nquit" | bc)
		suffix="KB"
	elif [ $TotalBytes -lt 1073741824 ]; then
		TotalSize=$(echo -e "scale=1 \n$TotalBytes/1048576 \nquit" | bc)
		suffix="MB"
	else
		TotalSize=$(echo -e "scale=1 \n$TotalBytes/1073741824 \nquit" | bc)
		suffix="GB"
	fi

	echo "${TotalSize} ${suffix}"

}

case $1 in

	*help )

		_help

	;;

	* )

		_show_size

	;;

esac
