diff --git a/apps/git/git.talon b/apps/git/git.talon index 9ba5687388..588a111a11 100644 --- a/apps/git/git.talon +++ b/apps/git/git.talon @@ -18,7 +18,7 @@ git stash [push] [] message []: git status$: "git status\n" git add patch$: "git add --patch\n" git show head$: "git show HEAD\n" -git diff$: "git diff\n" +git diff head$: "git diff\n" git diff (cached | cashed)$: "git diff --cached\n" # Convenience diff --git a/apps/github/cli/github_arguments.csv b/apps/github/cli/github_arguments.csv new file mode 100644 index 0000000000..061a0b3796 --- /dev/null +++ b/apps/github/cli/github_arguments.csv @@ -0,0 +1,37 @@ +Option, Spoken form +--help, help +cancel +checkout +checks +clone +close +comment +create +delete +diff +disable +download +edit +enable +fork +list +lock +login +logout +merge +ready +refresh +rename +reopen +rerun +review +run +setup-git, setup get +status +switch +sync +token +unlock +upload +view +watch diff --git a/apps/github/cli/github_cli.py b/apps/github/cli/github_cli.py new file mode 100644 index 0000000000..268450f060 --- /dev/null +++ b/apps/github/cli/github_cli.py @@ -0,0 +1,42 @@ +import csv +from pathlib import Path + +from talon import Context, Module, resource + +mod = Module() +ctx = Context() + +mod.list("github_command", desc="Github commands.") +mod.list("github_argument", desc="Command-line github options and arguments.") + +dirpath = Path(__file__).parent +arguments_csv_path = str(dirpath / "github_arguments.csv") +commands_csv_path = str(dirpath / "github_commands.csv") + + +def make_list(path): + with resource.open(path, "r") as f: + rows = list(csv.reader(f)) + mapping = {} + # ignore header row + for row in rows[1:]: + if len(row) == 0: + continue + if len(row) == 1: + row = row[0], row[0] + if len(row) > 2: + print("{path!r}: More than two values in row: {row}. Ignoring the extras.") + output, spoken_form = row[:2] + spoken_form = spoken_form.strip() + mapping[spoken_form] = output + return mapping + + +ctx.lists["self.github_argument"] = make_list(arguments_csv_path) +ctx.lists["self.github_command"] = make_list(commands_csv_path) + + +@mod.capture(rule="{user.github_argument}+") +def github_arguments(m) -> str: + """A non-empty sequence of github command arguments, preceded by a space.""" + return " " + " ".join(m.github_argument_list) diff --git a/apps/github/cli/github_cli.talon b/apps/github/cli/github_cli.talon new file mode 100644 index 0000000000..2945afd860 --- /dev/null +++ b/apps/github/cli/github_cli.talon @@ -0,0 +1,12 @@ +tag: terminal +and tag: user.git +- +get hub {user.github_command} []: + args = github_arguments or "" + "gh {github_command}{args} " + +# Convenience +github repo clone clipboard: + insert("gh repo clone ") + edit.paste() + key(enter) diff --git a/apps/github/cli/github_commands.csv b/apps/github/cli/github_commands.csv new file mode 100644 index 0000000000..7480f23329 --- /dev/null +++ b/apps/github/cli/github_commands.csv @@ -0,0 +1,13 @@ +Subcommand, Spoken form (optional) +auth, authenticate +browse +codespace, code space +gist +issue +org +project +release +pr, request +repo +run +workflow diff --git a/apps/jujitsu/jujitsu.py b/apps/jujitsu/jujitsu.py new file mode 100644 index 0000000000..7c06cab143 --- /dev/null +++ b/apps/jujitsu/jujitsu.py @@ -0,0 +1,43 @@ +import csv +import os +from pathlib import Path + +from talon import Context, Module, resource + +mod = Module() +ctx = Context() + +mod.list("jujitsu_command", desc="jujitsu commands.") +mod.list("jujitsu_argument", desc="Command-line jujitsu options and arguments.") + +dirpath = Path(__file__).parent +arguments_csv_path = str(dirpath / "jujitsu_arguments.csv") +commands_csv_path = str(dirpath / "jujitsu_commands.csv") + + +def make_list(path): + with resource.open(path, "r") as f: + rows = list(csv.reader(f)) + mapping = {} + # ignore header row + for row in rows[1:]: + if len(row) == 0: + continue + if len(row) == 1: + row = row[0], row[0] + if len(row) > 2: + print("{path!r}: More than two values in row: {row}. Ignoring the extras.") + output, spoken_form = row[:2] + spoken_form = spoken_form.strip() + mapping[spoken_form] = output + return mapping + + +ctx.lists["self.jujitsu_argument"] = make_list(arguments_csv_path) +ctx.lists["self.jujitsu_command"] = make_list(commands_csv_path) + + +@mod.capture(rule="{user.jujitsu_argument}+") +def jujitsu_arguments(m) -> str: + """A non-empty sequence of jujitsu command arguments, preceded by a space.""" + return " " + " ".join(m.jujitsu_argument_list) diff --git a/apps/jujitsu/jujitsu.talon b/apps/jujitsu/jujitsu.talon new file mode 100644 index 0000000000..3c32b89840 --- /dev/null +++ b/apps/jujitsu/jujitsu.talon @@ -0,0 +1,24 @@ +tag: terminal +and tag: user.git +- +jojo {user.jujitsu_command} []: + args = jujitsu_arguments or "" + "jj {jujitsu_command}{args} " +jojo describe [] message []: + args = jujitsu_arguments or "" + message = prose or "" + user.insert_between('jj describe{args} --message "{message}', '"') +jojo new [] message []: + args = jujitsu_arguments or "" + message = prose or "" + user.insert_between('jj new{args} --message "{message}', '"') +jojo commit [] message []: + args = jujitsu_arguments or "" + message = prose or "" + user.insert_between('jj commit{args} --message "{message}', '"') + +# Optimistic execution for frequently used commands that are harmless (don't +# change repository or index state). +jojo status$: "jj status\n" +jojo show head$: "jj show HEAD\n" +jojo diff head$: "jj diff\n" diff --git a/apps/jujitsu/jujitsu_arguments.csv b/apps/jujitsu/jujitsu_arguments.csv new file mode 100644 index 0000000000..3eea262698 --- /dev/null +++ b/apps/jujitsu/jujitsu_arguments.csv @@ -0,0 +1,35 @@ +Option, Spoken form +--add, add +--allow-backwards, allow backwards +--clear, clear +--colocate, colocate +--destination, destination +--dry-run, dry run +--from, from +--ignore-immutable, ignore immutable +--ignore-working-copy, ignore working copy +--insert-after, insert after +--insert-before, insert before +--interactive, interactive +--into, into +-h, help +--help, more help +--limit, limit +--no-edit, no edit +--no-pager, no pager +--patch, patch +--quiet, quiet +--remove, remove +--repo, repo +--repository, repository +--reset-author, reset author +--reversed, reversed +-r, revision +-r, revisions +--skip-empty, skip empty +--source, source +--stdin, standard in +--summary, summary +--to, to +--user, user +--what, what diff --git a/apps/jujitsu/jujitsu_commands.csv b/apps/jujitsu/jujitsu_commands.csv new file mode 100644 index 0000000000..6d610bbd82 --- /dev/null +++ b/apps/jujitsu/jujitsu_commands.csv @@ -0,0 +1,79 @@ +Subcommand, Spoken form (optional) +abandon +backout, back out +branch +branch create +branch delete +branch forget +branch list +branch rename +branch set +branch track +branch untrack, branch un track +cat +chmod, change mod +config +config edit +config get +config list +config path +config set +describe +diff +diffedit +duplicate +edit +files +fix +git +git clone +git export +git fetch +git import +git init, git initialize +git push +git remote +git remote add +git remote list +git remote remove +git remote rename +help +init, in it +interdiff, intersect diff +log +new +next +obslog, object log +operation +operation abandon +operation log +operation restore +operation undo +parallelize +prev, previous +rebase +resolve +restore +root +show +sparse +sparse edit +sparse list +sparse reset +sparse set +split +squash +status +Subcommand, Spoken form (optional) +tag +tag list +undo +unsquash, un squash +untrack, un track +version +workspace +workspace add +workspace forget +workspace list +workspace root +workspace update-stale, workspace update stale