Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 498
Oleg Avatar asked Dec 27 '13 14:12

Oleg


1 Answers

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.

like image 110
MattDMo Avatar answered Oct 03 '22 14:10

MattDMo