|
|
|
Use Growl to monitor long-running shell commands
Finally got this to work on Leopard after some fiddling.
First, as a previous commenter noted, if you have a .profile file in your home directory, bash will ignore a .bashrc file. You must put the script into your .profile instead.
Second, the script as written does not deal well with certain commands because the scripter left out some quotes.
Here is the script as it works for me in my .profile file:
. ~/.preexec.bash
# called before each command and starts stopwatch
function preexec () {
export PREEXEC_CMD="$BASH_COMMAND"
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}
if [ $elapsed -gt $max ]; then
growlnotify -n "Terminal" -m "took $elapsed secs" "${PREEXEC_CMD:-Terminal Command}"
fi
}
preexec_install
|
SearchFrom our Sponsor...Latest Lion HintsWhat's New:Hints1 new Hints in the last 24 hoursComments last 2 days
Links last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2013 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Powered by Geeklog Created this page in 0.09 seconds |
|