构建系统 - 崇高文本3

时间:2014-06-17 14:24:15

标签: batch-file build cmd sublimetext3

我有以下脚本名为" build-bat.sublime-build":

{
  "cmd": "build.bat",
  "working_dir": "$project_path",
  "windows" : {
      "shell": true
  }
}

脚本位于C:\ Users \ MyName \ AppData \ Roaming \ Sublime Text 3 \ Packages

我可以在Tools / Build Systems / build-bat中选择脚本然后通过CTRL + B运行它,或者通过在Tools / Build

中手动选择它来运行它

它什么都没发生。我什么也看不见,我没有收到任何错误。

它应该在当前目录中运行名为:build.bat的文件,其中放置了我正在处理的文件。但这并没有发生。

为什么?

4 个答案:

答案 0 :(得分:2)

将新的构建系统添加到sublime text 3之后,你必须重新启动sublime text 3.之后,上面的代码就可以了。

答案 1 :(得分:0)

您可以将build.bat重命名为make.bat,然后在ST中选择Make build system。只需按Ctrl+B,ST将尝试启动make命令,make.bat将被执行。输出将显示在ST的控制台中。

答案 2 :(得分:0)

这对我有用:


通过使用whitespaces分散参数,可以使用 "arg" , 处理路径和文件,例如:

[..., "/C", "START", "${file_path}", "${file_name}"]


将此粘贴​​到您的 Batch.sublime-build 文件中。

{
    "file_patterns": ["*.bat"],
    "selector": "source.Batch",
    // This runs the batch file in cmds' console
    "cmd": ["cmd", "/C", "START", "${file_path}", "${file_name}"]
}

然后,您的批处理文件可以在CMD的CLI中运行。我想也可以传递参数,但这可能是您的起点。

以上将运行cmd.exe并在其本机控制台中运行代码。这将接受您输入的 .bat 文件。


这里是可以保存为 BatchStConsole.sublime-build

的内部版本
{
    "file_patterns": ["*.bat"],
    "selector": "source.Batch",
    // This outputs to Sublime Texts' console
    "cmd": ["cmd", "/C", "${file}"]
}

以上内容将在Sublime Texts的控制台中运行代码。这将不接受您输入的 .bat 文件。但是对于调试还是有用的,因为它可以传递诸如本机CLI的任何参数,而无需交互。


相关帮助:

START https://ss64.com/nt/start.html

http://docs.sublimetext.info/en/latest/reference/build_systems/configuration.html#platform-specific-options

https://www.sublimetext.com/docs/3/build_systems.html

答案 3 :(得分:0)

创建新的构建系统并粘贴:

{
    "file_patterns": ["*.bat", "*.cmd"],
    "selector": "source.Batch",
    // opens CMD window and runs with full features. Uncomment what you like
    // "shell_cmd": "start \"CMD from Sublime - ${file_name}\" call \"${file}\"",
    "cmd": "cmd /c start \"CMD from Sublime - ${file_name}\" call \"${file}\"",

    // works on Sublime Text console and you can't input anything
    // "cmd": "cmd /c \"${file}\""
}

将其另存为 Batch.sublime-build 文件。在 ST3 和 ST4 版本中测试。

相关问题