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


Click here to return to the 'ZSH version' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
ZSH version
Authored by: Lutin on Oct 13, '07 06:41:10AM
I love this hint. Very good idea.

I adapted it to get it to work for zsh.
It seems to require a lot less code.
It works for me, but it might due to my particular config.
If it doesn't work for you, please let me know.

How to install:
Just add this two functions in your ~/.zshrc:


# Before a command execution
preexec() {
	# Define timer and cmd for growl notification
	export PREEXEC_TIME=$(date +'%s')
	export PREEXEC_CMD="the cmd: $1"
}

# After a command execution
precmd() {

	# Growl notify
	# Time after which trigger a growl notification
	DELAY_AFTER_NOTIFICATION=1
	
	# Get the start time, or set it to now if not set
	start=${PREEXEC_TIME:-`date +'%s'`}

	stop=$(date +'%s')
	
	let elapsed=$stop-$start
	
	if [ $elapsed -gt $DELAY_AFTER_NOTIFICATION ]; then
		growlnotify -n "Terminal" -m "took $elapsed secs" ${PREEXEC_CMD:-Some command}
	fi
}

Congratulations to sapporo for the original idea.
Enjoy!


[ Reply to This | # ]
ZSH version
Authored by: Lutin on Oct 13, '07 06:43:50AM

And change the variable DELAY_AFTER_NOTIFICATION to match your own needs (first line of code of function precmd).



[ Reply to This | # ]