Skip to content

Commit

Permalink
Added feature to allow user to set the path of the shell they which t…
Browse files Browse the repository at this point in the history
…o be invoke. Also added a preference (hdy.brackets-shell) for allowing the user to change this. Updated README and CHANGELOG
  • Loading branch information
johnhidey committed Dec 16, 2014
1 parent 447c16e commit f8e4e49
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
## Change Log

### v0.0.10
* BUG: Added feature for being able to specify the shell to use resolves the one outstanding issue with running on the *nix platform
* FEATURE: Updated *nix support for using different shells. The preference 'hdy.brackets-shell.shell is the string path
to the shell to be used. On Windows machines this will default to "cmd.exe" and on *nix machines this will default to
"/bin/sh". If you wish to you a different shell, say bash, just set this value to something like '/bin/bash'

### v0.0.9
* BUGFIX: Replace character with charCode 65533 to avoid showing garbage on command result on Windows (10?)
* DOC: updated readme file with extension options and usage
Expand Down
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -2,9 +2,6 @@ hdy.Brackets-Shell
==================
A brackets extension giving you access to the system shell within brackets.

##Screenshots
![][screenshot]

##Usage
Brackets-Shell adds a new icon on the right panel: click on it to toggle the shell's panel

Expand All @@ -13,6 +10,10 @@ Brackets-Shell adds the following options to your brackets.json file:

* `hdy.brackets-shell.dark`: set to true if you are using Bracket's dark theme (defaults to false)
* `hdy.brackets-shell.trackProject`: set to true if you want to have the Bracket's shell automatically be set to your project's root directory
* `hdy.brackets-shell.shell`: set to the path of your shell (i.e "/bin/sh" or "/bin/bash"). For Windows this should be set to "cmd.exe"

##Screenshots
![][screenshot]

##Change Log
Please see [`CHANGELOG.md`](CHANGELOG.md)
Expand Down
10 changes: 10 additions & 0 deletions main.js
Expand Up @@ -29,6 +29,16 @@ define(function (require, exports, module) {
Preferences.save();
}

if(Preferences.get("shell") === undefined) {
Preferences.definePreference("shell", "string", "cmd.exe");
if (brackets.platform === "win") {
Preferences.set("shell", "cmd.exe");
} else {
Preferences.set("shell", "/bin/sh");
}
Preferences.save();
}

AppInit.appReady(function () {

var projectWatcher = require("projectWatcher"),
Expand Down
14 changes: 10 additions & 4 deletions node/hdyShellDomain.js
Expand Up @@ -14,7 +14,7 @@
if false, return free memory only.
* @return {number} The amount of memory.
*/
function _execute(cmd, cwd, isWin) {
function _execute(cmd, cwd, isWin, shell) {

var spawn = require("child_process").spawn,
args,
Expand Down Expand Up @@ -46,11 +46,11 @@

if (isWin) {
args = ["/c", cmd];
cmd = "cmd.exe";
cmd = shell;
}
else {
args = ["-c", cmd];
cmd = "/bin/sh";
cmd = shell;
}

child = spawn(cmd, args, { cwd: cwd, env: process.env });
Expand All @@ -64,6 +64,7 @@
});

child.on("close", function () {
child.cwd
child.kill();
_domainManager.emitEvent("hdyShellDomain", "close", [enddir]);
});
Expand Down Expand Up @@ -132,8 +133,13 @@
},
{
name: "isWin",
type: "Boolean",
type: "boolean",
description: "Is Windows System ?"
},
{
name: "shell",
type: "string",
description: "Path of the Shell used to execute the commands"
}]
);

Expand Down
19 changes: 9 additions & 10 deletions package.json
@@ -1,9 +1,9 @@
{
"name": "hdy.brackets-shell",
"title": "Brackets Shell",
"version": "0.0.9",
"description": "Shell access within Brackets",
"homepage": "http://john.hidey.com/hdy.brackets-shell/",
"version": "0.0.10",
"description": "Shell access within Brackets. Want to run some shell command, install a node package, install from bower the list goes on and on. Well then, this extension is for you.",
"homepage": "https://github.com/johnhidey/hdy.brackets-shell/",
"repository": {
"type": "git",
"url": "https://github.com/johnhidey/hdy.brackets-shell"
Expand All @@ -14,12 +14,12 @@
},
"license": "MIT",
"keywords": [
"Command",
"Prompt",
"Shell",
"OS-X",
"Linux",
"Windows"
"command",
"prompt",
"shell",
"os-x",
"linux",
"windows"
],
"engines": {
"brackets": ">=0.40.0"
Expand All @@ -32,7 +32,6 @@
"mocha": "^2.0.1"
},
"dependencies": {
"splitargs": "^0.0.3",
"tree-kill": "^0.0.6"
}
}
11 changes: 6 additions & 5 deletions shellPanel.js
Expand Up @@ -69,7 +69,8 @@ define(function (require, exports, module) {
ShellDomain.exec("execute",
currentCommand.text(),
cwd,
brackets.platform === "win");
brackets.platform === "win",
_preferences.get("shell"));

CommandRoll.push(currentCommand.text());
console.info(CommandRoll);
Expand Down Expand Up @@ -159,12 +160,12 @@ define(function (require, exports, module) {

function replaceCharAtIndex(str, index, newChar) {
var array = str.split('');

array[index] = newChar;

return array.join('');
}

function _addShellOutput(data) {

var currentCommandGroup = $(".hdy-current"),
Expand Down Expand Up @@ -192,7 +193,7 @@ define(function (require, exports, module) {

_scrollToBottom();
}

function _addShellLine(cwd) {

var commandGroups = $(".hdy-command-groups"),
Expand Down

0 comments on commit f8e4e49

Please sign in to comment.