1

So, I wrote a fast script that you run with ". .script [name]". It's stupid simple, but I love it. Took me like an hour or so and a good dose of Stack Overflow. :P

I use Codekit on an iMac at work. I set it up as a hook, not understanding the coolness of those. So, I came home and tried it with Prepros. My conclusion: "Not sure. Don't think so."

How do I get Windows, OS X and Ubuntu/CentOS to watch a file in a specified project directory, and run the script I tell it to when I save it?

Steven Ventimiglia
  • 886
  • 1
  • 11
  • 19

2 Answers2

1

Without encoding support for each system's respective filesystem event notifier (linux has inotifytools, and I don't know what the rest do), you can poll for timestamp changes and run your hook if one takes place:

tm=$(stat -c%Y file) #get the m(odification)time of file
while : ; do 
   last_tm=$tm
   tm=$(stat -c%Y file) 
   [ "$last_tm" = "$tm" ] || echo "file changed"
   sleep 0.2 #poll interval
done
Petr Skocik
  • 58,047
  • 6
  • 95
  • 142
1

fswatch might be what you want. It support both linux, windows and MacOS.

http://emcrisostomo.github.io/fswatch/

ruijin
  • 186
  • 3