Skip to content

Commit

Permalink
Version 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhidey committed Jul 9, 2014
1 parent 662a260 commit 8752c8c
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
hdy.brackets-shell
==================
A brackets extension giving you access to the system shell within brackets.

License
=======
Expand Down
2 changes: 1 addition & 1 deletion commandTemplate.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="hdy-current">
<div class="hdy-command" autofocus contenteditable="true" data-cwd="">&nbsp;</div>
<div class="hdy-command" autofocus contenteditable="true" data-cwd="C:\">&nbsp;</div>
<div class="hdy-commandResult" ><pre></pre></div>
</div>
22 changes: 17 additions & 5 deletions node/hdyShellDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,27 @@ maxerr: 50, node: true */
*/
function _execute(cmd, cwd) {

shell.config.fatal = false;
var output,
dir;

shell.config.fatal = false;
shell.cd(cwd);
var result = shell.exec(cmd);
var newCwd = shell.pwd() || shell.exec('chdir');
cmd = cmd.trim();

if (cmd.slice(0, 3).toLowerCase() === 'cd ' ||
cmd.slice(0, 3).toLowerCase() === 'cd.') {
shell.cd(cmd.substring(2).trim());
output = '';
dir = process.cwd();
}
else {
output = shell.exec(cmd).output;
dir = cwd;
}

return {
data: result,
cwd: newCwd
data: output,
cwd: dir
};

}
Expand Down
32 changes: 14 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
{
"name": "hdy.brackets-shell",
"title": "Brackets Shell",
"description": "Shell access within Brackets",
"homepage": "https://github.com/johnhidey/hdy.brackets-shell",
"version": "0.0.2",
"author": "John Hidey (https://github.com/johnhidey/hdy.brackets-shell)",
"license": "MIT",
"keywords": [
"command",
"shell"
],
"engines": {
"brackets": ">=0.40.0"
},
"devDependencies": {
"karma": "^0.12.16",
"karma-brackets": "^0.2.1"
}
"name": "hdy.brackets-shell",
"title": "Brackets Shell",
"description": "Shell access within Brackets",
"homepage": "https://github.com/johnhidey/hdy.brackets-shell",
"version": "0.0.1",
"author": "John Hidey (https://github.com/johnhidey/hdy.brackets-shell)",
"license": "MIT",
"keywords": [
"command",
"shell"
],
"engines": {
"brackets": ">=0.40.0"
}
}
5 changes: 4 additions & 1 deletion shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ define(function (require, exports, module) {


function _execute(cmd, cwd) {
return ShellDomain.exec('execute', cmd, cwd);
var result = ShellDomain.exec('execute', cmd, cwd);


return result;
}

exports.execute = _execute;
Expand Down
4 changes: 2 additions & 2 deletions shellPanel.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
margin: 2px 0;
}

.hdy-command:before {
content: attr(data-content-before);
.hdy-command::before {
content: attr(data-cwd);
}

div:focus {
Expand Down
20 changes: 15 additions & 5 deletions shellPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ define(function (require, exports, module) {
var currentCommandGroup = $('.hdy-current'),
currentCommand = $('.hdy-command', currentCommandGroup).text(),
cwd = $('.hdy-command', currentCommandGroup).attr('data-cwd');
cwd = cwd.substring(0, cwd.length-1);

if (e.which == KeyEvent.DOM_VK_RETURN) {
e.preventDefault();

if (currentCommand.trim()) {
Shell.execute(currentCommand, cwd)
.done(function(result) {
_addShellLine(result.cwd.output.trim(), result.data.output.trim());
_addShellLine(result.cwd.trim(), result.data.trim());
})
.fail(function(err) {
if (err) {
Expand All @@ -83,6 +84,7 @@ define(function (require, exports, module) {

if (data) {
$('pre', currentCommandResult).text(data);
newCommand.attr('data-cwd', cwd);
} else {
currentCommandResult.html('');
}
Expand All @@ -93,7 +95,7 @@ define(function (require, exports, module) {
currentCommand.removeAttr('contenteditable');
}

newCommand.attr('data-content-before', (cwd || _getCommandPrompt()) + '>');
newCommand.attr('data-cwd', (cwd + '>' || _getCommandPrompt()));
commandGroups.append(newCommandGroup);

_focus();
Expand All @@ -103,9 +105,13 @@ define(function (require, exports, module) {
function _getCommandPrompt() {

var currentPath = ProjectManager.getProjectRoot().fullPath;
currentPath = currentPath.substring(0, currentPath.length-1);

return currentPath.substring(0, currentPath.length-1);
if (brackets.platform === "win") {
currentPath = currentPath.replace(/\//g, "\\") + '>';
}

return currentPath;
}

function _focus() {
Expand All @@ -117,12 +123,16 @@ define(function (require, exports, module) {
// Initialize the shellPanel
AppInit.appReady(function () {

var cwd = _getCommandPrompt();

$('.close', ShellPanel.$panel).click(_toggle);
$('.hdy-commandGroups .hdy-current .hdy-command').attr('data-cwd', 'C:\\');
$('.hdy-commandGroups .hdy-current .hdy-command').attr('data-cwd', _getCommandPrompt());
cwd = cwd.substring(0, cwd.length-1);

$('.hdy-commandGroups')
.on('keydown', '.hdy-current .hdy-command', _executeCommand);

_addShellLine();
_addShellLine(cwd);

});

Expand Down

0 comments on commit 8752c8c

Please sign in to comment.