GarouDan
GarouDan

Reputation: 3833

Key binding. How to run a external script (external command/program) in sublime text 2 when pressing a key?

I would like to run a external python script (or external command/program) when I press a key on Sublime Text 2.

How can I do this?

Upvotes: 8

Views: 10178

Answers (1)

GarouDan
GarouDan

Reputation: 3833

Here is a solution:

Preferences->Key Bindings - User and put this in the file (overriding the [,] inside):

[
    { "keys": ["<your shortucut>"], "command": "exec", "args": { "cmd": ["<path to your script>"]} }
]

Where <your shortcut> as the name says is the shortcut (examples: F1, ctrl+shift+F1, etc.) and <path to your command> is the location of your command (examples: echo, /home/user/scripts/my_script.py, ls, etc.)

Upvotes: 14

Related Questions