Sublime Text 3 plugin which executes given commands on file save
Clone or download
klaascuvelier Merge pull request #6 from timtianyang/patch-2
Enable running bash commands
Latest commit 2e4f817 Oct 17, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CommandOnSave.py Merge pull request #6 from timtianyang/patch-2 Oct 17, 2018
Main.sublime-menu update menu Jun 10, 2013
README.md Update readme with new info Mar 27, 2018

README.md

SublimeCommandOnSave

Sublime Text 3 plugin which executes given commands on file save

The Sublime Text 2 version of this plugin is available at ST2-CommandOnSave

Installation

The easiest way to install this plugin is via Sublime Package Control by adding an extra repository.

An other way is by cloning this repository into the package folder of Sublime

Usage

This plugin reads commands from the settings file. The commands settings-key is an associative array of paths and their commands. Everytime a file is saved, all commands for every matched path-key is executed.

The path of the file that is being save can get injected into your command with the _file_ placeholder.

If your command updates the content of the save file, the file will be reloaded in Sublime afterwards (thanks to @evanj).

For more info, see the examples

Examples

{
  "commands": {
    // example 1: project is in folder /Users/klaascuvelier/Projects/example/
    // rsync files to other server on save
    "/Users/klaascuvelier/Projects/example/": [
        "rsync -avz /Users/klaascuvelier/Projects/example/ server@server:/home/server/projects/example/ &"
    ],

    // example 2:
    // just run a bash script on save (you can put much more commands in there)
    "/Users/klaascuvelier/Projects/example2/": [
        "/Users/klaascuvelier/Projects/example2/command.sh &"
    ],

    // example 3:
    // everytime a file is saved, add, commit and push it to git
    "/Users/klaascuvelier/Projects/Sublime3/SublimeCommandOnSave/": [
        "git add -u",
        "git commit",
        "git push"
    ]
  }
}