Bash build system for Sublime Text

  • 20 Jun 2016
  • Matthew Wittering

How I setup Sublime Text to execute Bash scripts and display the output

Sublime Text 3 is my go to editor for Python and Bash scripts. I've spent a lot of time customising Sublime Text for both Linux and Window machines. Each time I configure a new machine, I always install GitGutter, OpenSCAD, Preap (a dark theme), SublimeAlignment, SublimePrettyJson and LettuceFarmer.

When writing stand alone Python scripts I use Ctrt + B to run the scripts and follow the output in the terminal letter box at the bottom of the window. I've found this page on GitHub which explains how to add the facility to build and run the bash script.

This has given me the same experience as the build functionality for Python. It's not a lot, but it does stops the need to swap between editor and terminal, reselecting and executing the same script. This has become a valuable way to improve my personal workflow when hacking together simple scripts to automate the repetitive and boring.

Where to begin. Start by click Tools > Build System > New Build System... Then paste the following into the new tab:

{
    "cmd": ["bash", "$file"],
    "selector": "source.shell"
}

And Save as Bash.sublime-build. When you're next working with a Bash script and press Ctrl + B, the Bash script will be executed.

References

  1. Bash build system for running currently open script in Sublime Text 2 ยท GitHub