diff --git a/applications/code.js b/applications/code.js new file mode 100644 index 0000000..1a97654 --- /dev/null +++ b/applications/code.js @@ -0,0 +1,88 @@ +const command = "command"; +const option = "option"; +const shift = "shift"; +const control = "control"; +const alt = "alt"; + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +serenade.app("code").command("explorer", async (api) => { + await api.pressKey("e", [command, shift]); +}); + +serenade.app("code").command("find in file", async (api) => { + await api.pressKey("f", [command]); +}); + +serenade.app("code").command("find in project", async (api) => { + await api.pressKey("f", [command, shift]); +}); + +serenade.app("code").command("previous file", async (api) => { + await api.pressKey("e", [command, shift]); + await api.pressKey("up"); + await api.pressKey("down", [command]); +}); + +serenade.app("code").command("next file", async (api) => { + await api.pressKey("e", [command, shift]); + await api.pressKey("down"); + await api.pressKey("down", [command]); +}); + +serenade.app("code").command("search <%search%>", async (api, matches) => { + await api.pressKey("p", [command]); + await api.typeText(matches.search); +}); + +serenade.app("code").command("select file <%number%>", async (api, matches) => { + const downs = parseInt(matches.number); + for (let index = 0; index < downs - 1; index++) { + await api.pressKey("down", [command]); + } + await api.pressKey("enter"); +}); + +serenade.app("code").command("quick search <%search%>", async (api, matches) => { + await api.pressKey("p", [command]); + await api.typeText(matches.search); + await sleep(300); + await api.pressKey("enter"); +}); + +serenade.app("code").command("next issue", async (api, matches) => { + await api.pressKey("f8", ["alt"]); +}); + +serenade.app("code").command("previous issue", async (api, matches) => { + await api.pressKey("f8", ["alt", "shift"]); +}); + +serenade.app("code").command("select matching", async (api, matches) => { + await api.evaluateInPlugin("editor.action.addSelectionToNextFindMatch") +}); + +serenade.app("code").command("close all tabs", async (api) => { + await api.evaluateInPlugin("openEditors.closeAll") +}); + +serenade.app("code").command("expand selection", async (api, matches) => { + await api.evaluateInPlugin("editor.action.smartSelect.expand") +}); + +serenade.app("code").command("new file", async (api, matches) => { + await api.evaluateInPlugin("explorer.newFile") + await api.typeText(".rb"); + await api.pressKey("left", [command]); +}); + +serenade.app("code").command("new folder", async (api, matches) => { + await api.evaluateInPlugin("explorer.newFolder") +}); + + +serenade.app("code").command("relative path copy", async (api) => { + await api.pressKey("c", [command, shift, option]); +}); diff --git a/applications/terminal.js b/applications/terminal.js index 059f78f..241cae0 100644 --- a/applications/terminal.js +++ b/applications/terminal.js @@ -31,56 +31,67 @@ serenade.app("terminal").command("cd <%text%>", async (api, cmd) => { await api.pressKey("tab") }); -serenade.app("terminal").command("open vim <%text%>", async (api, cmd) => { - await api.typeText("vim "); - await api.typeText(cmd.text); +serenade.app("terminal").command("start of line", async (api, cmd) => { + await api.pressKey("a", ["control"]) }); -serenade.app("terminal").command("open nvim <%text%>", async (api, cmd) => { - await api.typeText("nvim "); - await api.typeText(cmd.text); +serenade.app("terminal").command("end of line", async (api, cmd) => { + await api.pressKey("e", ["control"]) }); +serenade.app("terminal").command("next word", async (api, cmd) => { + await api.pressKey("right", ["option"]) +}); -// ------ -// Conda -// ------ - -serenade - .app("terminal") - .command("conda activate <%text%>", async (api, cmd) => { - await api.typeText("conda activate "); - await api.typeText(cmd.text); - }); - -serenade.app("terminal").command("conda create <%text%>", async (api, cmd) => { - await api.typeText("conda create -n "); - await api.typeText(cmd.text); - await api.typeText(" python=3.9"); +serenade.app("terminal").command("previous word", async (api, cmd) => { + await api.pressKey("left", ["option"]) }); -serenade.app("terminal").command("conda deactivate", async (api) => { - await api.typeText("conda deactivate"); +serenade.app("terminal").command("reload", async (api, cmd) => { + await api.typeText("reload!"); await api.pressKey("enter"); }); -serenade.app("terminal").command("conda env", async (api) => { - await api.typeText("conda info --envs"); +serenade.app("terminal").command("replay", async (api, cmd) => { + await api.typeText("reload!"); + await api.pressKey("enter"); + await api.pressKey("up"); + await api.pressKey("up"); await api.pressKey("enter"); }); -serenade.app("terminal").command("jupiter notebook", async (api) => { - await api.typeText("jupyter notebook"); - await api.pressKey("enter"); +serenade.app("terminal").command("clean", async (api, cmd) => { + await api.pressKey("k", ["command"]) }); -serenade.app("terminal").command("jupyter notebook", async (api) => { - await api.typeText("jupyter notebook"); - await api.pressKey("enter"); +serenade.app("terminal").command("continue", async (api, cmd) => { + await api.pressKey("q") }); -serenade.app("terminal").command("turn off jupiter", async (api) => { - await api.pressKey("c", ["control"]); - await api.pressKey("y"); - await api.pressKey("enter"); +serenade.app("terminal").command("search", async (api, cmd) => { + await api.pressKey("r", ["ctrl"]) +}); + +serenade.app("terminal").command("delete word", async (api, cmd) => { + await api.pressKey("w", ["ctrl"]) +}); + +serenade.app("terminal").command("delete line", async (api, cmd) => { + await api.pressKey("k", ["ctrl"]) +}); + +serenade.app("terminal").command("cancel", async (api, cmd) => { + await api.pressKey("c", ["ctrl"]) +}); + +serenade.app("terminal").command("redo", async (api, cmd) => { + await api.pressKey("up") + await api.pressKey("enter") +}); + +serenade.app("terminal").command("retest", async (api, cmd) => { + await api.pressKey("c", ["ctrl"]) + await api.pressKey("c", ["ctrl"]) + await api.pressKey("up") + await api.pressKey("enter") });