Sublime Forum

Is it possible to launch a shell command within keybindings?

#1

With the following shell command "shell_cmd": "explorer.exe /select,\"$file\"" I can open the Windows Explorer with the directory containing the current file and selecting the current file.

Is it possible to bind that shell_cmd to a key that I can invoke it simply, e.g. f12?

0 Likes

#2

The exec command is what’s used to execute external programs and build systems. So, to do that you could create a key binding like:

    { "keys": ["f12"], "command": "exec", "args": {
        "shell_cmd": "explorer.exe /select,\"$file\"",
    }},
1 Like

#3

Thanks Terence. That worked well.

0 Likes