在Sublime Text 3中保存文件时运行Shell脚本 [英] Run shell script when saving a file in Sublime Text 3

查看:798
本文介绍了在Sublime Text 3中保存文件时运行Shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是很好奇,当我在Linux上的Sublime Text 3中按CTRL + S时,是否可以自动运行shell脚本. 例如,在修改SASS时,它对于生成CSS可能很有用.

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.

谢谢.

推荐答案

签出 SublimeOnSaveBuild .您需要做的就是设置一个构建系统,例如 SASS构建 Nodejs 等或您自己的自定义构建系统,因此当您按 Ctrl B 时,它可以在没有干预的情况下正常运行.然后,将详细信息输入SublimeOnSaveBuild的配置文件中(该文件可让您按文件扩展名进行过滤,因此仅在保存.sass文件时触发它),并且已全部设置好-每次保存具有指定扩展名的文件.

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.

要设置配置文件,请首先打开 Preferences → Package Settings → SublimeOnSaveBuild → Settings - Default ,然后复制全部内容.关闭文件,然后将内容粘贴到 Preferences → Package Settings → SublimeOnSaveBuild → Settings - User 中,以自定义所需的任何内容.保存文件,一切应该从那里自动进行.设置"build_on_save": 0将禁用该​​插件.

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.

这篇关于在Sublime Text 3中保存文件时运行Shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆