Automate Octave script execution on save on Mac OS X
Let's say the octave script you are working on is located in ~/Documents/script.m . On save, you want it to be automagically executed by octave, including persistent figures.
Let's create a watchdog script ~/Documents/watchdog.sh:
#!/bin/bash while true do ATIME=`ls -al ~/Documents/script.m` if [[ "$ATIME" != "$LTIME" ]] then echo "Running octave script" echo "script" > ~/Documents/OCTAVEPIPE LTIME=$ATIME fi sleep 1 done
Make it executable: chmod u+x ~/Documents/watchdog.sh
Don't launch it yet. We are missing the OCTAVEPIPE pipe. Create it with mkpipe ~/Documents/OCTAVEPIPE
Launch the watchdog in a shell: ~/Documents/watchdog.sh or ./watchdog.sh if you are in the same directory.
In another shell, cd to /Documents/OCTAVEPIPE) | octave --interactive
Now edit and save your octave script, it shoud be executed after less than 1 second.