Sublime Forum

Sublime Text 2 key binding shell command not working

#1

I’m trying to bind a shell command on my key, but it doesn’t seem to be working.
I’m on OS X.
On Windows, replacing “shell” with “cmd” works.

[
{
	"keys": ["command+b"],
	"command": "exec",
	"args": {
		"shell": ["echo hello"]
	}
}
]

Pressing the shortcut give this output:
/bin/sh: -c: option requires an argument

0 Likes

#2

Try using shell_cmd instead.

0 Likes

#3

I had tried shell_cmd on Windows, which didn’t give me any output.
I just tried on OS X and I’m not getting any output.
Seems like it doesn’t do anything.

0 Likes

#4

I also forgot to mention that you should try removing the square brackets too:

"shell_cmd": "echo hello"

0 Likes

#5

:frowning: Still nothing
I also tried:

"shell_cmd": "\"echo hello\""
"shell": "\"echo hello\""
0 Likes

#6

From the error I get when simply running “shell”, it seems like for some reason the content is not being passed to command line when executing the command.

0 Likes

#7

Hmmm, I’m not sure what else to suggest now then.

Unfortunately I can only test on Windows where "shell_cmd": "echo hello" seems to work ok and outputs “hello” to the output panel.

Perhaps someone else who has more experience on OS X will be able to give you some better advice.

0 Likes

#8

Try upgrading to ST3 - maybe “shell_cmd” isn’t supported on ST2?

0 Likes