Last Updated: February 25, 2016
·
189
· unhammer

interrupt yourself when you start procrastinating due to long builds

Put this in your ~/.bashrc:

make () 
{ 
    start=$(date +%s);
    if command make "$@"; then
        icon=checkbox
    else
        icon=computer-fail
    fi
    nl='
';
    ive_switched_to_hacker_news=4
    if command -V notify-send &> /dev/null && [[ $(( $(date +%s) - ${start} )) -gt ${ive_switched_to_hacker_news} ]]; then
        notify-send 'Done compiling, back to work:' "${nl}$(hostname):${nl}$(pwd)" --icon=${icon} --expire-time=15000
    fi
}

and open a new terminal. The next time you type make, if it takes more than 4 seconds, you'll get a notification when it's done. That way you're pulled back from the rabbit-hole of procrastination due to long builds.

Requires notify-send (part of libnotify) though you could replace that with your notification program of choice.