I am writing several .gv files (graphviz) in the same directory and want to create a png file with neato immediately when I have saved one of them. I am on macOS 10.12.6, with zsh as my default shell, and I have installed entr from https://github.com/eradman/entr to monitor file changes. I have tried following command without any luck
$ echo $0
-zsh
$ ls *.gv | entr 'F="/_";neato -Tpng "$F" -o"${F/%\.gv/.png}"'
entr: exec F="/_";neato -Tpng "$F" -o"${F/%\.gv/.png}": No such file or directory
Following works
Simple printing of last modified file
$ ls *.gv | entr echo /_ # Press <Space> to manually trigger event to see last changed file /Users/hotschke/complete.gvUsing the same output name for all files:
$ ls *.gv | entr neato -Tpng /_ -oConstantname.pngReplace .gv with .png
$ F="/Users/hotschke/complete.gv";neato -Tpng "$F" -o"${F/%\.gv/.png}"
Note the special argument /_ of entr
The special
/_argument (somewhat analogous to$_in Perl) provides a quick way to refer to the first file that changed. When a single file is listed this is a handy way to avoid typing a pathname twice:
It would be great to have several answers using different tools (e.g. watchman, watchdog, fswatch, entr, launchd (mac-only); see also the discussion https://stackoverflow.com/q/1515730/)