// CUSTOM COMMAND REGISTRATION

JSterminal.register("tweet", {
  description: "share on Twitter",
  help: "it shares the current URL on Twitter, adding (in order of precedence) the text passed as argument or the page title in the status text",
  execute: function(argv){
    window.open("http://twitter.com/share?url="+location.href+"&text="+encodeURI(argv.join(" ") || document.title));
  }
});

JSterminal.register("s", {
  description: "search on Google",
  help: "it searches the string passed as argument on Google\nSynopsis:\n  s SEARCH_QUERY",
  execute: function(argv){
    window.open("http://www.google.com/search?q="+argv.join("+"));
  }
});

JSterminal.register("def", {
  description: "search for a definition",
  help: "it searches the string passed as argument for a definition on Google\nSynopsis:\n  s SEARCH_QUERY",
  execute: function(argv){
    window.open("http://www.google.com/search?q=define:"+argv.join("+"));
  }
});

JSterminal.register("w", {
  options: {
    "-l": {
      argument: true,
      description: "language (e.g. 'en' or 'it')"
    }
  },
  description: "search on Wikipedia",
  help: "it searches the string passed as argument on Wikipedia",
  execute: function(argv, options){
    window.open("http://www.wikipedia.org/search-redirect.php?search="+argv.join("+")+"&language="+(options["-l"] || "en"));
  }
});

JSterminal.register("deli", {
  description: "bookmark page on Delicious",
  help: "it bookmarks the current page on Delicious\nSynopsis:\n  deli [TITLE] [NOTES]",
  execute: function(argv){
    window.open("http://delicious.com/save?url="+location.href+"&title="+(argv[0] || document.title)+"&v=5&jump=yes&notes="+(argv[1]||""));
  }
});

JSterminal.register("tr", {
  description: "translate page with Google Translate",
  help: "it translates the current page with Google Translate\nSynopsis:\n  tr [DESTINATION_LANGUAGE]",
  execute: function(argv){
    window.open("http://translate.google.com/translate?u="+location.href+"&tl="+(argv[0] || "en"));
  }
});

JSterminal.register("iten", {
  description: "Italian to English translation",
  help: "it translates a word or expression from Italian to English using WordReference\nSynopsis:\n  iten WORD",
  execute: function(argv){
    window.open("http://www.wordreference.com/iten/"+argv.join("+").replace(/ +/, "+"));
  }
});

JSterminal.register("enit", {
  description: "English to Italian translation",
  help: "it translates a word or expression from English to Italian using WordReference\nSynopsis:\n  enit WORD",
  execute: function(argv){
    window.open("http://www.wordreference.com/enit/"+argv.join("+").replace(/ +/, "+"));
  }
});

JSterminal.register("map", {
  description: "search on Google Maps",
  help: "it searches the string passed as argument on Google Maps\nSynopsis:\n  map SEARCH_QUERY",
  execute: function(argv){
    window.open("http://www.google.com/maps?q="+argv.join("+"));
  }
});

JSterminal.register("img", {
  description: "search on Google Image Search",
  help: "it searches the string passed as argument on Google Image Search\nSynopsis:\n  img SEARCH_QUERY",
  execute: function(argv){
    window.open("http://www.google.com/images?q="+argv.join("+"));
  }
});

JSterminal.register("tube", {
  description: "search on YouTube",
  help: "it searches the string passed as argument on YouTube\nSynopsis:\n  tube SEARCH_QUERY",
  execute: function(argv){
    window.open("http://www.youtube.com/results?search_query="+argv.join("+"));
  }
});

JSterminal.register("mail", {
  description: "send link by email",
  help: "it opens your default email application pre-filling a new email with a link to the current page\nSynopsis:\n  mail [RECIPIENTS] [SUBJECT]",
  execute: function(argv){
    window.open("mailto:"+(argv[0]||"")+"?subject="+(argv[1]||document.title)+"&body="+location.href+"%0A%0A"+argv.join("+"));
  }
});

JSterminal.register("gmail", {
  description: "send link by email using Gmail",
  help: "it opens Gmail pre-filling a new email with a link to the current page\nSynopsis:\n  gmail [RECIPIENTS] [SUBJECT]",
  execute: function(argv){
    window.open("https://mail.google.com/mail/?view=cm&tf=1&to=" + (argv[0] || "") + "&cc=&su=" + (argv[1] || document.title) + "&body=" + location.href + "&fs=1",'_blank','location=yes,menubar=yes,resizable=yes,width=800,height=600');
  }
});
@@ -413,24 +413,173 @@
 ster(%22s%22, %7B%0A
+  options: %7B%0A    %22-d%22: %7B%0A      argument: true,%0A      description: %22top level domain to use (e.g. 'com', 'de' or 'it'). Default is 'com'.%22%0A    %7D%0A  %7D,%0A
   descriptio
@@ -709,32 +709,41 @@
 e: function(argv
+, options
 )%7B%0A    window.op
@@ -756,35 +756,60 @@
 tp://www.google.
-com
+%22+(options%5B%22-d%22%5D %7C%7C %22com%22)+%22
 /search?q=%22+argv
@@ -1223,16 +1223,21 @@
 anguage 
+code 
 (e.g. 'e

add -l option to command s