Run shell script when saving a file in Sublime Tex

2020-02-28 12:32发布

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.

1条回答
时光不老,我们不散
2楼-- · 2020-02-28 13:12

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.

查看更多
登录 后发表回答