Run a script when I do "Ctrl + S" on any file?


#1

I’ve found the keymap.cson and added:

_'body':_

_ ‘ctrl-s’: ‘core:save’_

But I also want it to run a batch file in an absolute/relative directory. Is there any way to do this?


#2

I didn’t add the underscores… Idk how to remove those from main post


#3

It’s possible to create an event listener in init.coffee that runs the script whenever a file is saved. However, I want to make sure that you want what you say you want. Do you really want the script to run when any file is saved?

This a sample of what you might write if you want to run it when you save any file and you’re using process-palette to run the script.

atom.workspace.observeTextEditors (editor) ->
  editor.onDidSave (saved) ->
    atom.commands.dispatch editor.element, "process-palette:run-my-script"

#4

Perfect, this is exactly what I need.

I’ll figure out the “run-my-script” part