Closed trymeouteh closed 2 weeks ago
We are unlikely to implement a arbitrary run-command-on-save feature. This is for a number of reasons, not least of which is it's unclear what should happen if you save a file twice in quick succession (should the cmd be spawed twice? Should the first one be killed? etc). This is why most bundler implement their own watchers.
But the existence of inotify
(Linux) and fswatch
(MacOS) should make this relatively trivial to implement your own version with the same caveats.
For example on MacOS (brew install fswatch
):
fswatch -0 ~/code/zed | xargs -0 -I {} sh -c 'echo "File changed: {}"; echo {} >> /tmp/my.log'
Or on Linux:
inotifywait -m -e modify,create,delete --format '%w%f' ~/source/zed | xargs -I {} sh -c 'echo "File changed: {}"; echo "{}" >> /tmp/a.log'
Check for existing issues
Describe the feature
The ability to run custom commands when you save specific file extensions in Zed. Can be used to act as a "watch" feature when working with code to run bundlers when the user saves their code.
If applicable, add mockups / screenshots to help present your vision of the feature
run-on-save.json
file in workplace directory when a file is savedrun-on-save.json
file contains any commands to run for the file extension being savedIt is important to ask the user if it should run the commands first for security reasons. But once the user approves, it will always run the commands. If the
run-on-save.json
file is modified, it will prompt the user and ask them again to ensure the file was not updated with malicious commands.