diff --git a/main.js b/main.js index 963b852..88c7a73 100644 --- a/main.js +++ b/main.js @@ -33,6 +33,8 @@ define(function (require, exports, module) { Preferences.definePreference("shell", "string", "cmd.exe"); if (brackets.platform === "win") { Preferences.set("shell", "cmd.exe"); + } else if (brackets.platform === "mac") { + Preferences.set("shell", "/bin/bash"); } else { Preferences.set("shell", "/bin/sh"); } diff --git a/node/hdyShellDomain.js b/node/hdyShellDomain.js index 8ac403b..c852f7f 100644 --- a/node/hdyShellDomain.js +++ b/node/hdyShellDomain.js @@ -14,7 +14,7 @@ if false, return free memory only. * @return {number} The amount of memory. */ - function _execute(cmd, cwd, isWin, shell) { + function _execute(cmd, cwd, platform, shell) { var spawn = require("child_process").spawn, args, @@ -36,6 +36,9 @@ catch (e) {} } + + var isWin = (platform === "win"); + var isMac = (platform === "mac"); // clearing the console with clear or clr? if ((cmd.toLowerCase() === "clear" && !isWin) || @@ -49,7 +52,14 @@ cmd = shell; } else { - args = ["-c", cmd]; + if (!isMac) { + args = ["-c", cmd]; + } + else { + var macEnvironment = "for i in $(defaults read $HOME/.MacOSX/environment | sed -nE 's/^(.+)= (.+\");/\\1/p' | sed -nE 's/^[ \\t]*//p'); do eval export $i=$(defaults read $HOME/.MacOSX/environment $i); done" + args = ["-c", macEnvironment + ";" + cmd]; + } + cmd = shell; } diff --git a/shellPanel.js b/shellPanel.js index a76d388..3099f11 100644 --- a/shellPanel.js +++ b/shellPanel.js @@ -69,7 +69,7 @@ define(function (require, exports, module) { ShellDomain.exec("execute", currentCommand.text(), cwd, - brackets.platform === "win", + brackets.platform, _preferences.get("shell")); CommandRoll.push(currentCommand.text());