Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Use Growl to monitor long-running shell commands' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Growl to monitor long-running shell commands
Authored by: 4ndrew on Oct 13, '07 02:20:41PM
I'm using exclude list of parameters instead of "gnotif-method":

My ~/.profile file:


export PREEXEC_EXCLUDE_LIST="mc less bash"

. ~/.preexec.bash

# called before each command and starts stopwatch
function preexec () {
	export PREEXEC_CMD=`echo $1 | awk '{ print $1; }'`
	export PREEXEC_TIME=$(date +'%s')
}

# called after each command, stops stopwatch
# and notifies if time elpsed exceeds threshold
function precmd () {
	stop=$(date +'%s')
	start=${PREEXEC_TIME:-$stop}
	let elapsed=$stop-$start
	max=${PREEXEC_MAX:-10}
	
	for i in ${PREEXEC_EXCLUDE_LIST:-}; do
	  if [ "x$i" = "x$PREEXEC_CMD" ]; then
	    max=999999;
	    break;
	  fi
	done
	
	if [ $elapsed -gt $max ]; then
		growlnotify -n "iTerm" -m "took $elapsed secs" ${PREEXEC_CMD:-Shell Command}
	fi
}

preexec_install


[ Reply to This | # ]