Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal and VS code commands #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions applications/code.js
Original file line number Diff line number Diff line change
@@ -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]);
});
81 changes: 46 additions & 35 deletions applications/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
});