Sapiens Search


How to run external programs/commands/functions in Sublime Text 2?

1-Preferences->Key Bindings - User
2- Override [`,`] to:
{ "keys": ["<Your shortucut>"], "command": "exec", "args": { "cmd"["<Path to your command>"]} }

Where <Your shortcut> could be f1, ctrl+shift+f1, etc. and <Path to your command> echo, /home/garou/scripts/, ls, etc.


        { "keys": ["f1"], "command": "exec", "args": { "cmd": ["/media/data/Scripts/myScript"]} },

Arcam Sapientia

This virtually could run any system command.


  1. Is there any way to make the path to the script relative to the sublime data directory? I have an issue where I have synchronised settings across more than one computer but the location for the data directory (i.e. the username in Windows) changes, and I want to specify a script which lives in the data folder.

  2. Ned Martin, I'm currently not using sublime, but the easy way to do this, is simple create a script that reads files (and execute programs) the lives at your specific directory. For example something like:

    cd path\to\your\directory

    cd /path/to/your/directory

    Everything you need to do (for example, change directories or remove files or create) you should and can do over your script.

    I hope it helps.

  3. I used this method. I am getting "[Errno 8] Exec format error" while executing from sublime key press.
    The same script I use in cmd works fine on terminal.

    On ubuntu 12.04.