Skip to content

Instantly share code, notes, and snippets.

@Polyterative
Last active December 7, 2022 10:53
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 Polyterative/349bf7a03564cf5a5e750f3fe35fa4e7 to your computer and use it in GitHub Desktop.
Save Polyterative/349bf7a03564cf5a5e750f3fe35fa4e7 to your computer and use it in GitHub Desktop.
Serenade script
let intellij = serenade.app("intellij");
let global = serenade.global();
let chrome = serenade.app("chrome");
// Display an alert box with the message "Hello, world!"
// alert("Hello, world!");
// Define global shortcut keys for common actions
global.key("cut", "x", ["ctrl"]); // Cut the selected text
global.key("copy", "c", ["ctrl"]); // Copy the selected text
global.command("copy all", async (api, matches) => {
await api.pressKey("a", ["ctrl"]); // Select all text
await api.delay(50); // Wait 50 milliseconds
await api.pressKey("c", ["ctrl"]); // Copy the selected text
await api.delay(50); // Wait 50 milliseconds
await api.pressKey("escape", []); // Close any open menus or dialogs
});
//delete all
global.command("delete all", async (api, matches) => {
await api.pressKey("a", ["ctrl"]); // Select all text
await api.delay(50); // Wait 50 milliseconds
await api.pressKey("delete", []); // Delete the selected text
await api.delay(50); // Wait 50 milliseconds
await api.pressKey("escape", []); // Close any open menus or dialogs
});
global.key("drop", "v", ["ctrl"]); // Paste the clipboard contents at the cursor position
global.key("special drop", "v", ["windows"]); // Paste the clipboard contents using special formatting options
global.key("undo", "z", ["ctrl"]); // Undo the last action
global.key("all", "a", ["ctrl"]); // Select all text
global.key("full screen", "f11", []); // Toggle full-screen mode
global.key("fullscreen", "f11", []); // Toggle full-screen mode
global.key("switch", "tab", ["alt"]); // Switch between open windows or tabs
global.key("maximize", "up", ["windows"], 3); // Maximize the current window
global.key("minimize", "down", ["windows"]); // Minimize the current window
// Define shortcut keys for deleting text
global.key("slash", "backspace", ["ctrl"]); // Delete the previous word
global.key("bash", "backspace", []); // Delete the previous character
global.key("smash", "delete", ["ctrl"]); // Delete the next word
// Define shortcut keys for navigation
global.key("push", "right", ["ctrl"]); // Move the cursor to the next word
global.key("pop", "left", ["ctrl"]); // Move the cursor to the previous word
global.key("confirm", "enter", []); // Confirm a selection or action
global.key("slap", "enter", []); // Confirm a selection or action
global.key("yes", "enter", []); // Confirm a selection or action
global.key("no", "escape", []); // Cancel a selection or action
// Block certain commands from being spoken to force me using shorter commands
global.command("edit", (api) => {}); // Do nothing
global.command("enter", (api) => {}); // Do nothing
global.command("escape", (api) => {}); // Do nothing
// global.command("me <%text%>", async (api, matches) => {
// await api.runCommand("type "+matches.text); // Type the requested text
// });
// Define shortcut keys for switching between applications
global.key("desktop", "d", ["windows"]); // Switch to the desktop
global.key("chrome", "1", ["windows"]); // Switch to the first application in the taskbar
global.key("mail", "2", ["windows"]); // Switch to the second application in the taskbar
global.key("calendar", "3", ["windows"]); // Switch to the third application in the taskbar
global.key("code", "4", ["windows"]); // Switch to the fourth application in the taskbar
global.key("teams", "5", ["windows"]); // Switch to the fifth application in the taskbar
// Define global shortcut keys for scrolling
global.key("scroll", "pagedown", []); // Scroll down one page
global.key("page", "pagedown", []); // Scroll down one page
global.key("scroll up", "pageup", []); // Scroll up one page
global.key("top", "home", ["ctrl"]);
global.key("bottom", "end", ["ctrl"]);
global.key("home", "home", []);
global.key("end", "end", []);
// Define commands for searching and navigating in Google Chrome
chrome.command("find <%text%>", async (api, matches) => {
await api.pressKey("f", ["ctrl"]); // Open the search bar
await api.typeText(matches.text); // Type the search query
});
chrome.command("google <%text%>", async (api, matches) => {
await api.pressKey("t", ["ctrl"]); // Open a new tab
await api.pressKey("k", ["ctrl"]); // Focus the search bar
await api.typeText(matches.text); // Type the search query
await api.pressKey("enter"); // Perform the search
});
chrome.command("google this", async (api, matches) => {
await api.pressKey("c", ["ctrl"]); // Copy the selected text
await api.pressKey("t", ["ctrl"]); // Open a new tab
await api.pressKey("k", ["ctrl"]); // Focus the search bar
await api.pressKey("v", ["ctrl"]); // Paste the copied text
await api.pressKey("enter"); // Perform the search
});
// Define shortcut keys for navigating search results in the "find" panel
chrome.key("next", "g", ["ctrl"]); // Move to the next search result
chrome.key("previous", "g", ["ctrl", "shift"]); // Move to the previous search result
// Define shortcut keys for opening developer tools in Google Chrome
chrome.key("console", "j", ["ctrl", "shift"]); // Open the JavaScript console
// terminal commands
// serenade.app("terminal").command("clear", (api) => {
// api.pressKey("l", ["ctrl"]);
// }
// serenade.app("").key("next", "g", ["ctrl"]);
// intellij commands
intellij.key("windows", "f12", ["ctrl", "shift"]); // Open the project window
intellij.key("style", "f1", []); // Reformat the current file according to the configured code style settings
intellij.key("fix indent", "i", ["ctrl", "alt"]); // Fix the indentation of the current file
intellij.key("refactor", "f12", []); // Change name
intellij.key("change signature", "f6", ["ctrl"]); // Change the signature of the current method
intellij.key("inside", "b", ["ctrl"]); // Go to the definition of the symbol under the cursor
intellij.key("find usages", "f7", ["alt"]); // Find all usages of the symbol under the cursor
intellij.key("a", "alpha", []); // Write "a"
// up&&down method
intellij.key("north", "up", ["alt"]);
intellij.key("south", "down", ["alt"]);
intellij.command("head", async (api) => {
await api.runCommand("class");
// await api.delay(100);
await api.pressKey("right",["ctrl"], 2 );
await api.delay(50);
await api.pressKey("`",[], );
// await api.pressKey("right",["ctrl"] );
});
// Select the first option in the list
global.command("first option", (api) => {
api.pressKey("enter", ); // Select the currently highlighted option
});
// Select the second option in the list
global.command("second option", (api) => {
api.pressKey("down", ); // Move the selection down
api.pressKey("enter", ); // Select the currently highlighted option
});
// Select the third option in the list
global.command("third option", (api) => {
api.pressKey("down", ); // Move the selection down
api.pressKey("down", ); // Move the selection down
api.pressKey("enter", ); // Select the currently highlighted option
});
// Select the fourth option in the list
global.command("fourth option", (api) => {
api.pressKey("down", ); // Move the selection down
api.pressKey("down", ); // Move the selection down
api.pressKey("down", ); // Move the selection down
api.pressKey("enter", ); // Select the currently highlighted option
});
// Select the fifth option in the list
global.command("fifth option", (api) => {
api.pressKey("down", ); // Move the selection down
api.pressKey("down", ); // Move the selection down
api.pressKey("down", ); // Move the selection down
api.pressKey("down", ); // Move the selection down
api.pressKey("enter", ); // Select the currently highlighted option
});
// operations
intellij.key("duplicate", "d", ["ctrl"]);
// selection manipulation commands (intellij)
// Increase the selection by one more level
intellij.key("more", "`", []);
// Decrease the selection by one level
intellij.key("less", "~", []);
// Shrink the selection to the next smallest enclosing element
intellij.key("shrink", "~", []);
// select to the end
intellij.key("trace right", "end", ["shift"]);
// select to the start
intellij.key("trace left", "home", ["shift"]);
// // copy to the end
// intellij.command("transport end", async (api) => {
// api.pressKey("end", ["shift"]);
// await api.delay(15);
// api.pressKey("c", ["ctrl"]);
// });
// // copy to the start
// intellij.command("transport start", async (api) => {
// api.pressKey("home", ["shift"]);
// await api.delay(15);
// api.pressKey("c", ["ctrl"]);
// });
// Select the current item and copy it to the clipboard
intellij.command("take", async (api) => {
api.pressKey("`", []);
await api.delay(15);
api.pressKey("c", ["ctrl"]);
});
// Increase the selection by one level and then shrink it to the next smallest enclosing element
intellij.command("alpha", async (api) => {
api.pressKey("`", []);
await api.delay(15);
api.pressKey("`", []);
});
// Increase the selection by two levels and then shrink it to the next smallest enclosing element
intellij.command("bravo", async (api) => {
api.pressKey("`", []);
await api.delay(15);
api.pressKey("`", []);
await api.delay(15);
api.pressKey("`", []);
});
// Increase the selection by three levels and then shrink it to the next smallest enclosing element
intellij.command("charlie", async (api) => {
api.pressKey("`", []);
await api.delay(15);
api.pressKey("`", []);
await api.delay(15);
api.pressKey("`", []);
await api.delay(15);
api.pressKey("`", []);
});
// Insert a comma followed by a space
intellij.command("comma", async (api, matches) => {
await api.pressKey(",", []);
await api.pressKey("space", []);
});
// Insert a pair of parentheses and move the cursor inside
intellij.command("args", async (api, matches) => {
await api.pressKey("(", []);
await api.pressKey(")", []);
await api.pressKey("left", []);
});
// Insert a pair of double quotes and move the cursor inside
intellij.command("string", async (api, matches) => {
await api.pressKey("\"", []);
await api.pressKey("\"", []);
await api.pressKey("left", []);
});
// Insert a pair of curly braces and move the cursor inside
intellij.command("object", async (api, matches) => {
await api.pressKey("{", []);
await api.pressKey("}", []);
await api.pressKey("left", []);
});
// Insert a pair of square brackets and move the cursor inside
intellij.command("array", async (api, matches) => {
await api.pressKey("[", []);
await api.pressKey("]", []);
await api.pressKey("left", []);
});
// Copy the entire contents of the current editor to the clipboard
intellij.command("copy all", async (api, matches) => {
await api.pressKey("a", ["ctrl"]);
await api.delay(15);
await api.pressKey("c", ["ctrl"]);
await api.delay(500);
await api.pressKey("escape", []);
});
// Toggle comment on/off for the selected text
intellij.key("comment", "f5", []);
// Scroll the current selection out of view
intellij.key("out", "f6", []);
// Insert a new line below the current line and move the cursor to the new line
intellij.key("below", "enter", ["ctrl", "shift"]);
// Insert a new line above the current line and move the cursor to the new line
intellij.key("above", "enter", ["ctrl"]);
// Reformat the current file according to the configured code style settings
intellij.key("format", "f1", []);
// Commit the current changes to the version control system (VCS)
intellij.key("send code", "f10", []);
// Commit the current changes to the version control system (VCS)
intellij.key("commit", "f10", []);
// Version control system (VCS) management
// Go to the previous change in the current file
intellij.key("previous change", "up", ["ctrl", "alt"]);
// Go to the next change in the current file
intellij.key("next change", "down", ["ctrl", "alt"]);
// Undo the changes made to the current file
intellij.key("undo changes", "z", ["alt"]);
// Find
// Open the find panel
intellij.key("find", "f", ["ctrl"]);
// Open the find dialog and search for the specified text
intellij.command("find <%text%>", async (api, matches) => {
await api.pressKey("f", ["ctrl"]);
await api.typeText(matches.text);
});
// Open the replace panel
intellij.key("replace", "r", ["ctrl"]);
// Go to the next match for the current search
intellij.key("next", "l", ["ctrl"]);
// Go to the previous match for the current search
intellij.key("previous", "f3", ["shift"]);
//
intellij.command("equals", async (api, matches) => {
await api.pressKey("space", []);
await api.pressKey("=", []);
await api.pressKey("space", []);
});
intellij.key("open round", "(", []);
intellij.key("close round", ")", []);
//
intellij.key("open array", "[", []);
intellij.key("open square", "[", []);
intellij.key("close array", "]", []);
intellij.key("close square", "]", []);
//
intellij.key("open curly", "{", []);
intellij.key("close curly", "}", []);
intellij.key("screenshot", "A", ["ctrl", "shift", "alt"]);
// General IntelliJ commands
intellij.key("split", ".", ["ctrl", "shift", "alt"]);
intellij.key("spit down", ",", ["ctrl", "shift", "alt"]);
intellij.key("reopen tab", "t", ["ctrl", "shift"]);
intellij.key("clean tabs", "c", ["alt"]);
// Debugging commands
intellij.key("breakpoint", "f8", ["ctrl"]);
intellij.key("step", "f9", ["shift"]);
// Bookmarking commands
intellij.key("bookmark", "f11", ["ctrl"]);
intellij.key("locations", "f11", ["ctrl", "shift"]);
// Help commands
intellij.key("help", "enter", ["alt"]);
intellij.key("fix", "enter", ["alt", "shift"]);
intellij.key("imports", "enter", ["alt", "shift"]);
// Refactoring commands
intellij.key("documentation", "q", ["ctrl"]);
intellij.key("docs", "q", ["ctrl"]);
intellij.key("extract method", "m", ["ctrl", "alt"]);
intellij.key("extract variable", "v", ["ctrl", "alt"]);
intellij.key("show parameters", "P", ["ctrl"]);
//
// serenade.app("intellij").key("complete", "space", ["shift"]);
// show error
intellij.key("what", "f2", []);
intellij.key("surround with", "t", ["alt"]);
//moving statements around
intellij.key("move up", "up", ["ctrl", "shift"]);
intellij.key("move down", "down", ["ctrl", "shift"]);
// Navigation commands
intellij.key("back", "left", ["alt"]);
intellij.key("forward", "right", ["alt"]);
intellij.key("last", "backspace", ["alt"]);
// General commands
intellij.key("list", "1", ["alt"]);
intellij.key("fullscreen", "f11", []);
intellij.key("settings", "s", ["ctrl", "alt"]);
// Git commands
intellij.key("git", "2", ["alt"]);
intellij.key("update git", "g", ["ctrl"]);
intellij.command("search", async (api) => {
api.pressKey("shift", []);
await api.delay(5);
api.pressKey("shift", []);
});
intellij.key("big search", "f", ["ctrl", "shift"]);
intellij.key("recent files", "e", ["ctrl"]);
intellij.key("recent locations", "e", ["ctrl", "shift"]);
// Code folding commands
intellij.key("fold", "-", ["ctrl"]);
intellij.key("expand", "+", ["ctrl"]);
// editing commands
intellij.key("dot", ".", []);
intellij.key("show", "space", ["shift"]);
// Run
intellij.key("run debug", "f9", ["shift"]);
intellij.key("run last", "f10", ["shift"]);
intellij.key("show run", "4", ["alt"])
// serenade.app("intellij").key("run", "b", ["ctrl", "alt", "shift"]);
//
// https://serenade.ai/docs/api/#snippets
// serenade.app("intellij").key("public", "public", []);
intellij.command("public", async (api, matches) => {
await api.typeText("public ");
});
intellij.command("protected", async (api, matches) => {
await api.typeText("protected ");
});
intellij.command("build bs", async (api, matches) => {
await api.typeText("readonly simpleResult$: BehaviorSubject<string> = new BehaviorSubject<string>();");
});
serenade.language("javascript").snippet(
"chain",
".pipe(" +
"<%cursor%>" +
")",
{ }
);
serenade.language("javascript").snippet(
"subscribe",
".subscribe(" +
"<%cursor%>" +
")",
{ }
);
// serenade.language("javascript").snippet(
// "",
// ".pipe(" +
// "<%cursor%>" +
// ")",
// { }
// );
// serenade.language("javascript").snippet(
// "chain",
// ".pipe(" +
// "<%cursor%>" +
// ")",
// { "identifier": ["identifier", "pascal"] }
// );
//
intellij.command("this", async (api, matches) => {await api.typeText("this");});
intellij.command("true", async (api, matches) => {await api.typeText("true");});
intellij.command("false", async (api, matches) => {await api.typeText("false");});
intellij.key("a", "air", []); // Write "a"
intellij.key("b", "bat", []); // Write "b"
intellij.key("c", "cap", []); // Write "c"
intellij.key("d", "drum", []); // Write "d"
intellij.key("e", "each", []); // Write "e"
intellij.key("f", "fine", []); // Write "f"
intellij.key("g", "gust", []); // Write "g"
intellij.key("h", "harp", []); // Write "h"
intellij.key("i", "sit", []); // Write "i"
intellij.key("j", "jury", []); // Write "j"
intellij.key("k", "kruch", []); // Write "k"
intellij.key("l", "look", []); // Write "l"
intellij.key("m", "made", []); // Write "m"
intellij.key("n", "neaf", []); // Write "n"
intellij.key("o", "odd", []); // Write "o"
intellij.key("p", "pit", []); // Write "p"
intellij.key("q", "quech", []); // Write "q"
intellij.key("r", "red", []); // Write "r"
intellij.key("s", "sun", []); // Write "s"
intellij.key("t", "trap", []); // Write "t"
intellij.key("u", "urge", []); // Write "u"
intellij.key("v", "vest", []); // Write "v"
intellij.key("w", "whale", []); // Write "w"
intellij.key("x", "plex", []); // Write "x"
intellij.key("y", "yank", []); // Write "y"
intellij.key("z", "zip", []); // Write "z"
//
// What are the Common Two Letter Words?
// The Common Two Letter Words are is, an, at, or, of, do, to, so, no, on, in, ex, hi, me, we, ok, bi, us, un, go, etc.
// serenade.language("javascript").snippet(
// "extends",
// "extends <%cursor%>",
// { },
// "class"
// );
//
/* Serenade Custom Commands
In this file, you can define your own custom commands with the Serenade API.
For instance, here's a custom automation that opens your terminal and runs a command:
serenade.global().command("make", api => {
api.focusApplication("terminal");
api.typeText("make clean && make");
api.pressKey("return");
});
And, here's a Python snippet for creating a test method:
serenade.language("python").snippet(
"test method <%identifier%>",
"def test_<%identifier%>(self):<%newline%><%indent%>pass",
{ "identifier": ["underscores"] }
"method"
);
For more information, check out the Serenade API documentation: https://serenade.ai/docs/api
*/
/* Serenade Custom Commands
In this file, you can define your own custom commands with the Serenade API.
For instance, here's a custom automation that opens your terminal and runs a command:
serenade.global().command("make", api => {
api.focusApplication("terminal");
api.typeText("make clean && make");
api.pressKey("return");
});
And, here's a Python snippet for creating a test method:
serenade.language("python").snippet(
"test method <%identifier%>",
"def test_<%identifier%>(self):<%newline%><%indent%>pass",
{ "identifier": ["underscores"] }
"method"
);
For more information, check out the Serenade API documentation: https://serenade.ai/docs/api
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment