Skip to content

Instantly share code, notes, and snippets.

@aehlke
Forked from jamesmacaulay/gist:860763
Created May 26, 2011 08:53

Revisions

  1. aehlke revised this gist May 26, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.eclass
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ growl_about_long_running_commands() {
    max=${PREEXEC_MAX:-10}

    if [ $elapsed -gt $max ]; then
    growlnotify -H localhost --image="$img" -n "LongRunningCommandGrowler" -m "exited with status $exitstatus after $elapsed secs" ${PREEXEC_CMD:-Some command}
    growlnotify --image="$img" -n "LongRunningCommandGrowler" -m "exited with status $exitstatus after $elapsed secs" ${PREEXEC_CMD:-Some command}
    fi
    PREEXEC_TIME=
    PREEXEC_CMD=
  2. @jamesmacaulay jamesmacaulay revised this gist Mar 9, 2011. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion gistfile1.eclass
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@

    preexec_functions+='save_preexec_time'
    save_preexec_time() {
    export PREEXEC_CMD="$(history $HISTCMD)"
    export PREEXEC_CMD="$(history $HISTCMD | sed 's/ *[0-9]* *//')"
    export PREEXEC_TIME=$(date +'%s')
    }

    @@ -24,4 +24,7 @@ growl_about_long_running_commands() {
    if [ $elapsed -gt $max ]; then
    growlnotify -H localhost --image="$img" -n "LongRunningCommandGrowler" -m "exited with status $exitstatus after $elapsed secs" ${PREEXEC_CMD:-Some command}
    fi
    PREEXEC_TIME=
    PREEXEC_CMD=
    }

  3. @jamesmacaulay jamesmacaulay revised this gist Mar 8, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.eclass
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # long-running command growler
    # hooks for zsh, built on bash version at http://hints.macworld.com/article.php?story=20071009124425468

    preexec_functions+='save_preexec_time'
    save_preexec_time() {
  4. @jamesmacaulay jamesmacaulay created this gist Mar 8, 2011.
    26 changes: 26 additions & 0 deletions gistfile1.eclass
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    # long-running command growler

    preexec_functions+='save_preexec_time'
    save_preexec_time() {
    export PREEXEC_CMD="$(history $HISTCMD)"
    export PREEXEC_TIME=$(date +'%s')
    }

    precmd_functions+='growl_about_long_running_commands'
    growl_about_long_running_commands() {
    exitstatus=$?
    if [ $exitstatus -eq 0 ]; then
    img="$HOME/.zsh/images/pass.png"
    else
    img="$HOME/.zsh/images/fail.png"
    fi

    stop=$(date +'%s')
    start=${PREEXEC_TIME:-$stop}
    let elapsed=$stop-$start
    max=${PREEXEC_MAX:-10}

    if [ $elapsed -gt $max ]; then
    growlnotify -H localhost --image="$img" -n "LongRunningCommandGrowler" -m "exited with status $exitstatus after $elapsed secs" ${PREEXEC_CMD:-Some command}
    fi
    }