Debug scripts from command line with Zend Debugger

Usage:

~/cli_zend_debug.sh script.php <param1> <param..>

Source of cli_zend_debug.sh

#!/bin/bash
 
IP=`who am i | sed -r "s/.*\((.*)\).*/\\1/"`
PORT=10137
 
CHECK_PORT=`nc -t $IP $PORT < /dev/null; echo $?`
 
if [ $CHECK_PORT -ne 0 ]; then
	echo "Cannot connect to $IP:$PORT"
	exit 1
fi
 
PHP_IDE_CONFIG="serverName=CLI" QUERY_STRING="start_debug=1&debug_host=$IP&use_remote=1&debug_port=$PORT&debug_stop=1&debug_fastfile=1&original_url=http://cli.devil&debug_session_id=10000" /usr/local/bin/php "$@"