简体   繁体   中英

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.

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 Ctrl B . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM