Giter VIP home page Giter VIP logo

sublimecommandonsave's Introduction

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"
    ]
  }
}

sublimecommandonsave's People

Contributors

klaascuvelier avatar

Stargazers

Daniel Hartmann avatar Jeff Triplett avatar Filip avatar jon roethke avatar Toby Wang avatar Hristo Chakarov avatar Matt H avatar Richard Liaw avatar  avatar normal-cock avatar err avatar Jose Soto avatar Francisco Pinzón avatar James Benner avatar Jim Yeh avatar Collin Kindrom avatar

Watchers

 avatar  avatar James Cloos avatar  avatar

sublimecommandonsave's Issues

Two errors on sublime text4

On sublime text4 with python3.3 as default compiler, there're two errors:

  1. NameError: global name 're' is not defined
    solution:
    insert
import re
  1. FileNotFoundError: [Errno 2] No such file or directory: 'rsync ...'
    solution:
    insert
import shlex

then replace

 process = subprocess.Popen(command,
                        stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

by

 process = subprocess.Popen(shlex.split(command),
                        stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

Unable to run node commands in script

I am trying to execute s.th. as simple as

uglifycss app.css > app.min.css

in a bash script on save. But the output file app.min.css is always empty.

The same command works fine in Sublime Text 2 (using the ST2 plugin), on the same computer.

All "native" bash commands work as expected.

I can't figure out what might be the problem. Do you have any ideas?

Settings file per Project

Hi there,
I would really like to use this Plugin, but curious if you can add a feature to allow the settings to be in a file on the root of the project.
Ex.
save_commands.json (Preferred)
.commandonsave
command_on_save.json
Etc.

The reason is I would really like to allow the settings for this to be transmitted with GIT. This way another developer that pulls down my code it will start working for him right away as long as he has the Plugin installed.

Bonus points if you decide to also have this available on Atom.
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.