Skip to content

Instantly share code, notes, and snippets.

@cgranade
Created November 13, 2008 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgranade/24632 to your computer and use it in GitHub Desktop.
Save cgranade/24632 to your computer and use it in GitHub Desktop.
Basic first attempt at a command to run programs on the shell.
/* This is a template command */
CmdUtils.CreateCommand({
name: "shell",
icon: "http://example.com/example.png",
homepage: "http://sites.google.com/site/cgranade/",
author: { name: "Christopher Granade", email: "cgranade@gmail.com"},
license: "GPL",
description: "A short description of your command",
help: "how to use your command",
takes: {"command": noun_arb_text},
preview: function( pblock, input ) {
var template = "Will execute <tt>${cmd}</tt>.";
pblock.innerHTML = CmdUtils.renderTemplate(template, {"cmd": input.text});
},
execute: function(input) {
// For now, must have full path.
var cmd = input.text;
var proc = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(cmd);
proc.init(file);
proc.run(true, null, 0);
CmdUtils.setSelection("Ran command successfully.");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment