Skip to content

Instantly share code, notes, and snippets.

@pentaphobe
Created March 5, 2014 01:13
Show Gist options
  • Save pentaphobe/9359255 to your computer and use it in GitHub Desktop.
Save pentaphobe/9359255 to your computer and use it in GitHub Desktop.
Rudimentary Bash events

Rudimentary Shell Events

Sometimes I want commands in one terminal to happen only after commands in another terminal have finished.

This is a temporary solution to a problem likely better solved by someone else somewhere :)

Usage

In one terminal:

$> on someEvent ; echo done!

In the other:

$> some_long_process ; trigger someEvent

This will cause the first terminal to halt until some_long_process has finished.

#!/bin/sh
##
#
# Very basic shell event listener (still needs proper work)
#
# TODO: support multiple instances of events
# TODO: usage text / help
#
##
fname=/tmp/event_$1.txt
while [ ! -f "$fname" ]
do
# echo waiting...
sleep 2
done
rm $fname
#!/bin/bash
##
#
# Very basic shell event trigger (still needs proper work)
#
# TODO: support multiple instances of events
# TODO: usage text / help
#
##
fname=/tmp/event_$1.txt
touch $fname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment