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

count_processes_help ()
{

	white=$(bs_ng_echo $white)
	orange=$(bs_ng_echo $orange)
	green=$(bs_ng_echo $green)

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

}

count_processes ()
{

	case $1 in
		*help )
			count_processes_help
		;;

		* )
			procs=$(ps ax | wc -l | awk '{print $1}')

			if [[ $procs -lt 10 ]]; then
				echo "000$procs"
			elif [[ $procs -lt 100 ]]; then
				echo "00$procs"
			elif [[ $procs -lt 1000 ]]; then
				echo "0$procs"
			fi
		;;
	esac

}
