Curious Curious - 1 year ago 81
Linux Question

Run shell script when saving a file in Sublime Text 3

I'm just curious, is it possible to run shell script automatically when I hit CTRL+S in Sublime Text 3 on Linux.
It may be useful for generating CSS when modifying SASS, for example.

Thank you.

Answer Source

Check out SublimeOnSaveBuild. All you need to do is set up a build system like SASS Build, LESS-build, Nodejs, etc., or your own custom build system, so that it's working without intervention when you press CtrlB. Then, enter the particulars into SublimeOnSaveBuild's config file (which allows you to filter by file extension, so you only trigger it when saving .sass files, for example) and you're all set - the build will trigger each time you save a file with the specified extension.

To set up the config file, first open Preferences → Package Settings → SublimeOnSaveBuild → Settings - Default, and copy the entire contents. Close the file, and paste the contents into Preferences → Package Settings → SublimeOnSaveBuild → Settings - User, customizing anything you wish. Save the file, and things should proceed automagically from there. Setting "build_on_save": 0 will disable the plugin.