Skip to content

Instantly share code, notes, and snippets.

@satyr
Created January 30, 2009 18:07
Show Gist options
  • Save satyr/55171 to your computer and use it in GitHub Desktop.
Save satyr/55171 to your computer and use it in GitHub Desktop.
Runs shell commands.
CmdUtils.CreateCommand({
name: "shell",
icon: 'chrome://ubiquity/skin/icons/application_view_list.png',
takes: {command: noun_arb_text},
description: 'Runs shell command.',
execute: function(inp, mod){
var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile),
proc = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess),
cmd = this._cmd(inp).split(/\s+/), [exe] = cmd, args = cmd.slice(1);
file.initWithPath(exe);
proc.init(file);
proc.run(false, args, args.length);
},
preview: function(pbl, inp){ pbl.innerHTML = this._cmd(inp) },
_cmd: function(inp)
Application.prefs.getValue('extensions.ubiquity.shell',
'C:\\Windows\\System32\\cmd.exe /c')+
' '+ inp.text,
author: 'satyr'.link('http://d.hatena.ne.jp/murky-satyr'), license: 'MIT',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment