| 📦 Turbo Python 6fc62ea k33g 10h ago | 1 | # turbo-python tools. |
| 2 | # |
| 3 | # Each [[tool]] becomes one line of the Python menu, in the order they appear |
| 4 | # here. name is what the menu shows; a letter between tildes is its hot key, and |
| 5 | # no two tools should claim the same one. |
| 6 | # |
| 7 | # command goes to "sh -c", so pipes, globs and && work: one entry can be a |
| 8 | # whole sequence. |
| 9 | # |
| 10 | # menu says which menu it appears in. Leave it out and the tool goes into the |
| 11 | # Python menu; name anything else and that menu is created for you, in the order |
| 12 | # the names first appear here. A tool that has nothing to do with Python belongs |
| 13 | # in one of your own: |
| 14 | # |
| 15 | # [[tool]] |
| 16 | # name = "~E~cho" |
| 17 | # command = "echo TADA" |
| 18 | # menu = "Tools" |
| 19 | # |
| 20 | # A {{label}} in a command is a value the editor asks for before running it, in |
| 21 | # a box titled after the tool. The text between the braces is what it asks for: |
| 22 | # |
| 23 | # [[tool]] |
| 24 | # name = "~A~dd a dependency" |
| 25 | # command = "uv add {{package}}" |
| 26 | # |
| 27 | # The value is quoted, so a path with a space in it stays one argument. Add ... |
| 28 | # inside the braces when you mean several arguments rather than one value: |
| 29 | # |
| 30 | # [[tool]] |
| 31 | # name = "Test ~o~ne" |
| 32 | # command = "uv run pytest {{extra flags...}}" |
| 33 | # |
| 34 | # Double braces, not single. Single ones appear in real commands — awk '{print |
| 35 | # $1}' and find . -exec rm {} + are both ordinary things to put here — and |
| 36 | # neither is asking you for anything. |
| 37 | # |
| 38 | # output says where what the command prints goes: |
| 39 | # popup a dialog that fills in as it runs, and says the exit code (default) |
| 40 | # terminal a terminal window, for anything that reads the keyboard or runs long |
| 41 | # editor an editing window once it has finished, to search with Ctrl-F |
| 42 | # |
| 43 | # Commands run in the directory the editor was started in, which is why they |
| 44 | # see the whole project when you start from its root. |
| 45 | # |
| 46 | # Everything below goes through uv, which creates the environment, resolves the |
| 47 | # dependencies, and runs the tools inside it — so no command here needs an |
| 48 | # environment to have been activated first. Replace `uv run x` with `x` if you |
| 49 | # would rather activate one yourself. |
| 50 | |
| 51 | [[tool]] |
| 52 | name = "~E~nvironment" |
| 53 | # The one command that has to come first in a new project: it creates the |
| 54 | # virtual environment everything else runs inside. The name is asked for rather |
| 55 | # than fixed, because .venv is only the usual answer and not the only one. |
| 56 | command = "uv venv {{directory, usually .venv}}" |
| 57 | output = "popup" |
| 58 | |
| 59 | [[tool]] |
| 60 | name = "~S~ync" |
| 61 | command = "uv sync" |
| 62 | output = "popup" |
| 63 | |
| 64 | [[tool]] |
| 65 | name = "~F~ormat" |
| 66 | command = "uv run ruff format ." |
| 67 | output = "popup" |
| 68 | |
| 69 | [[tool]] |
| 70 | name = "~L~int" |
| 71 | command = "uv run ruff check ." |
| 72 | output = "popup" |
| 73 | |
| 74 | [[tool]] |
| 75 | name = "~T~est" |
| 76 | command = "uv run pytest" |
| 77 | output = "popup" |
| 78 | |
| 79 | [[tool]] |
| 80 | name = "~R~un" |
| 81 | command = "uv run {{script}}" |
| 82 | # A terminal, not a popup: a program that reads the keyboard has to be able to |
| 83 | # be answered, and one that runs long has to be able to be interrupted. Python |
| 84 | # scripts are usually both. |
| 85 | output = "terminal" |
| 86 | |
| 87 | # A tool naming a `menu` gets a menu of its own on the bar. Nothing above does, |
| 88 | # so every tool above is in the Python menu. This one is in a menu called Tools, |
| 89 | # which appears between Python and Help — that is the whole mechanism. |
| 90 | |
| 91 | [[tool]] |
| 92 | name = "~E~cho" |
| 93 | command = "echo 🎉 tada!" |
| 94 | menu = "Tools" |
| 95 | output = "terminal" |