Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonw/llm-cmd
Use LLM to generate and execute commands in your shell
https://github.com/simonw/llm-cmd
Last synced: 6 days ago
JSON representation
Use LLM to generate and execute commands in your shell
- Host: GitHub
- URL: https://github.com/simonw/llm-cmd
- Owner: simonw
- License: apache-2.0
- Created: 2024-03-26T15:00:34.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-09-09T23:32:12.000Z (5 months ago)
- Last Synced: 2024-10-18T07:53:30.873Z (4 months ago)
- Language: Python
- Size: 12.7 KB
- Stars: 116
- Watchers: 3
- Forks: 11
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome-github-stars - simonw/llm-cmd - Use LLM to generate and execute commands in your shell (Python)
README
# llm-cmd
[](https://pypi.org/project/llm-cmd/)
[](https://github.com/simonw/llm-cmd/releases)
[](https://github.com/simonw/llm-cmd/actions/workflows/test.yml)
[](https://github.com/simonw/llm-cmd/blob/main/LICENSE)Use LLM to generate and execute commands in your shell
## Installation
Install this plugin in the same environment as [LLM](https://llm.datasette.io/).
```bash
llm install llm-cmd
```
## UsageThis command could be **very dangerous**. Do not use this unless you are confident you understand what it does and are sure you could spot if it is likely to do something dangerous.
Run `llm cmd` like this:
```bash
llm cmd undo last git commit
```
It will use your [default model](https://llm.datasette.io/en/stable/setup.html#setting-a-custom-default-model) to generate the corresponding shell command.This will then be displayed in your terminal ready for you to edit it, or hit `` to execute the prompt.
If the command doesnt't look right, hit `Ctrl+C` to cancel.
## The system prompt
This is the prompt used by this tool:
> Return only the command to be executed as a raw string, no string delimiters
wrapping it, no yapping, no markdown, no fenced code blocks, what you return
will be passed to subprocess.check_output() directly.
>
> For example, if the user asks: undo last git commit
>
> You return only: git reset --soft HEAD~1## Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd llm-cmd
python3 -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
llm install -e '.[test]'
```
To run the tests:
```bash
pytest
```