pay-respects/README.md

235 lines
7.4 KiB
Markdown
Raw Normal View History

2023-07-31 21:38:04 +02:00
# Pay Respects
2023-07-30 18:40:18 +02:00
2024-11-19 18:45:19 +01:00
Typed a wrong command or don't know what to do? Pay Respects will suggest a fix to your console command by simply pressing `F`!
2023-07-30 18:40:18 +02:00
2023-08-04 03:18:31 +02:00
- 🚀 **Blazing fast suggestion**: You won't notice any delay for asking suggestions!
2024-12-08 16:52:53 +01:00
- 🎯 **Accurate results**: Suggestions are verified before being prompted to the user, no `sudo` suggestions when you are using `doas`!
2024-11-19 18:45:19 +01:00
- ✏️ **Easy to write rules**: You don't need to know Rust. The rules are written in a TOML file!
2024-12-08 20:49:22 +01:00
- 🔩 **Modular**: TOML not your taste? Add sources using your favorite language with a custom module!
2024-12-08 16:48:06 +01:00
- 🤖 **AI Support**: AI module comes in aid when there is no rule for your error!
2024-12-07 18:23:01 +01:00
- 🪶 **Tiny binary size**: Not even 1MB for core features!
2023-08-04 03:18:31 +02:00
2025-01-02 16:27:22 +01:00
![showcase](https://raw.githubusercontent.com/iffse/static-assets/refs/heads/main/pay-respects/showcase.gif)
2023-07-31 19:25:19 +02:00
2023-07-31 21:38:04 +02:00
## How to Pay Respects
2023-07-30 18:40:18 +02:00
Please follow the instruction for your shell:
<details>
2024-11-18 14:53:10 +01:00
<summary>Bash / Zsh / Fish</summary>
2023-07-31 14:22:20 +02:00
2024-12-07 18:23:01 +01:00
> Append the following line to your configuration file:
2024-12-30 00:20:49 +01:00
> ```sh
> eval "$(pay-respects bash --alias)"
> eval "$(pay-respects zsh --alias)"
> pay-respects fish --alias | source
> ```
2024-12-07 18:23:01 +01:00
> Arguments:
> - `--alias [alias]`: Alias to a custom key, defaults to `f`
2024-11-23 22:57:28 +01:00
> - `--nocnf`: Disables `command_not_found` handler
2023-08-04 15:40:45 +02:00
2024-12-09 16:21:49 +01:00
> Manual aliasing (**DEPRECATED**, do not use):
2024-12-30 00:20:49 +01:00
> ```sh
2024-11-23 19:00:07 +01:00
> alias f="$(pay-respects bash)"
> alias f="$(pay-respects zsh)"
> alias f="$(pay-respects fish)"
> ```
</details>
<details>
<summary>Nushell</summary>
2024-11-18 14:53:10 +01:00
> Add the following output to your configuration file:
2024-12-30 00:20:49 +01:00
> ```sh
2024-12-11 17:48:07 +01:00
> pay-respects nushell --alias [<alias>]
> ```
2023-07-30 18:40:18 +02:00
> Or save it as a file:
2024-12-30 00:20:49 +01:00
> ```sh
2024-12-11 17:48:07 +01:00
> pay-respects nushell --alias [<alias>] | save -f ~/.pay-respects.nu
> ```
> and source from your config file:
2024-12-30 00:20:49 +01:00
> ```sh
> source ~/.pay-respects.nu
> ```
2023-07-31 15:06:30 +02:00
</details>
<details>
<summary>PowerShell</summary>
2024-12-30 00:20:49 +01:00
> Append the following output to your profile:
> ```pwsh
2024-12-30 00:20:49 +01:00
> pay-respects pwsh --alias [<alias>] [--nocnf]
> ```
> Or directly pipe the output to your profile:
> ```pwsh
> pay-respects pwsh --alias [<alias>] [--nocnf] >> $PROFILE
> ```
</details>
2024-11-18 22:21:51 +01:00
<details>
<summary>Custom initialization for arbitrary shell</summary>
> pay-respects only requires 2 environment variables to function:
>
> - `_PR_SHELL`: The binary name of the current working shell.
> - `_PR_LAST_COMMAND`: The last command.
>
> pay-respects echos back, if applicable, a `cd` command that can be evaluated by the current working shell.
2024-11-20 21:16:14 +01:00
2024-11-18 22:21:51 +01:00
> General example:
2024-12-30 00:20:49 +01:00
> ```sh
2024-11-18 22:21:51 +01:00
> eval $(_PR_SHELL=sh _PR_LAST_COMMAND="git comit" pay-respects)
> ```
2025-03-13 21:06:21 +01:00
> Following variables are not required, but can be used to reduce unnecessary operations:
>
> - `_PR_ALIAS`: A list of aliases to commands. Separated by newlines with zsh-like formatting, e.g. `gc=git commit`
> - `_PR_ERROR_MSG`: Error message from the previous command. `pay-respects` will rerun previous command to get the error message if absent
> - `_PR_EXECUTABLES`: A space separated list of commands/executables. `pay-respects` will search for `$PATH` if absent
2024-11-18 22:21:51 +01:00
</details>
2024-12-11 16:22:52 +01:00
<details>
<summary>Environment variable configurations</summary>
> - `_PR_LIB`: Directory of modules, analogous to `PATH`. If not provided, search in `PATH` or compile-time provided value.
> - `_PR_PACKAGE_MANAGER`: Use defined package manager instead of auto-detecting alphabetically
</details>
You can now **press `F` to Pay Respects**!
2024-10-19 16:53:16 +02:00
2023-07-30 22:10:55 +02:00
## Installing
2024-11-16 23:27:35 +01:00
Install from your package manager if available:
[![Packaging status](https://repology.org/badge/vertical-allrepos/pay-respects.svg)](https://repology.org/project/pay-respects/versions)
2023-07-30 22:10:55 +02:00
2024-12-18 15:07:22 +01:00
<details>
<summary>Instructions for package managers</summary>
2025-01-07 21:32:37 +01:00
> | OS / Distribution | Repository | Instructions |
> |-------------------|-----------------|---------------------------------------------------|
> | Arch Linux | [AUR] | `paru -S pay-respects` (`-bin`) |
> | Arch Linux (ARM) | [Arch Linux CN] | `sudo pacman -S pay-respects` |
> | MacOS / *Any* | [timescam] | `brew install timescam/homebrew-tap/pay-respects` |
> | NixOS / *Any* | [nixpkgs] | `nix-env -iA nixos.pay-respects` |
2024-12-18 15:07:22 +01:00
[AUR]: https://aur.archlinux.org/
[Arch Linux CN]: https://github.com/archlinuxcn/repo
[nixpkgs]: https://github.com/NixOS/nixpkgs
2025-01-07 21:32:37 +01:00
[timescam]: https://github.com/timescam/homebrew-tap
2024-12-18 15:07:22 +01:00
</details>
Alternatively, install pre-built binaries from [GitHub releases](https://github.com/iffse/pay-respects/releases). An [install script](./install.sh) is available:
2024-12-30 00:20:49 +01:00
```sh
2024-11-22 12:57:07 +01:00
curl -sSfL https://raw.githubusercontent.com/iffse/pay-respects/main/install.sh | sh
```
<details>
2024-12-18 15:07:22 +01:00
<summary>Cargo / Compile from source (any OS/architecture supported by Rust)</summary>
> This installation requires you to have Cargo (the Rust package manager) installed.
2024-11-20 21:16:14 +01:00
2024-12-08 17:46:43 +01:00
> Install from [crates.io](https://crates.io/), modules are optional
2024-12-30 00:20:49 +01:00
> ```sh
2024-12-08 17:46:43 +01:00
> cargo install pay-respects
> cargo install pay-respects-module-runtime-rules
> cargo install pay-respects-module-request-ai
> ```
2024-11-20 21:16:14 +01:00
> Clone from git and install, suitable for adding custom compile-time rules:
2024-12-30 00:20:49 +01:00
> ```sh
> git clone --depth 1 https://github.com/iffse/pay-respects
> cd pay-respects
2024-12-08 17:46:43 +01:00
> cargo install --path core
> cargo install --path module-runtime-rules
> cargo install --path module-request-ai
> ```
2024-09-24 18:47:31 +02:00
</details>
2024-12-08 16:52:53 +01:00
## Rules & Modules
2023-07-30 20:08:28 +02:00
2024-12-08 17:38:07 +01:00
See the following pages:
- [Writing rules (TOML)](./rules.md)
- [Custom modules](./modules.md)
2023-07-30 20:08:28 +02:00
2024-11-19 16:19:22 +01:00
## AI Integration
2024-11-20 12:01:34 +01:00
> **Disclaimer**: You are using AI generated content on your own risk. Please double-check its suggestions before accepting.
2024-11-20 11:56:27 +01:00
2024-12-08 17:38:07 +01:00
AI suggestions should work out of the box with `request-ai` module installed.
2024-11-19 16:19:22 +01:00
2025-02-12 17:22:00 +01:00
An API key is included with the source (your distribution might have stripped them out). It should always work unless I can no longer afford this public service or rate limits are reached. If it's useful to you, **please share this project and spread the word**. Also consider making a donation to keep its public usage alive:
2024-11-19 16:19:22 +01:00
<div>
<a
href="https://liberapay.com/iff/donate"
target="_blank"
rel="noreferrer"
><img
src="https://liberapay.com/assets/widgets/donate.svg"
alt="Donate using Liberapay"
/></a
>
<a href="https://ko-fi.com/iffse" target="_blank" rel="noreferrer"
><img
2024-11-19 23:49:11 +01:00
height='30'
2024-11-19 16:19:22 +01:00
src="https://www.vectorlogo.zone/logos/ko-fi/ko-fi-ar21.svg"
alt="Donate using Ko-fi"
style="height: 30px;"
/></a
>
<br />
<a href="https://iffse.eu.org/stripe" target="_blank" rel="noreferrer"
><img
2024-11-19 23:49:11 +01:00
height='30'
2024-11-19 16:19:22 +01:00
src="https://cdn.brandfolder.io/KGT2DTA4/at/8vbr8k4mr5xjwk4hxq4t9vs/Stripe_wordmark_-_blurple.svg"
alt="Donate using Stripe"
style="height: 30px;"
/></a
>
<a
href="https://www.paypal.com/donate/?hosted_button_id=QN7Z7ZHRAAFZL"
target="_blank"
rel="noreferrer"
><img
2024-11-19 23:49:11 +01:00
height='30'
2024-11-19 16:19:22 +01:00
src="https://upload.wikimedia.org/wikipedia/commons/b/b5/PayPal.svg"
alt="Donate using PayPal"
style="height: 25px; margin-bottom: 3px;"
/></a
>
</div>
2025-02-12 17:22:00 +01:00
[AI and API configurations](./module-request-ai/README.md)
2024-11-19 16:19:22 +01:00
2024-11-15 20:11:26 +01:00
## Contributing
2023-07-30 18:40:18 +02:00
2023-08-04 03:04:26 +02:00
Current option to write rules should cover most of the cases.
We need more rule files, contributions are welcomed!
2023-07-30 18:40:18 +02:00
2025-01-03 21:26:13 +01:00
Also see [development status](./development.md) for contribution opportunities.
2024-10-19 18:30:10 +02:00
This project is hosted at various sites, choose the one that suits you best:
- [Codeberg](https://codeberg.org/iff/pay-respects)
- [GitHub](https://github.com/iffse/pay-respects)
- [GitLab](https://gitlab.com/iffse/pay-respects)
2024-12-29 16:16:13 +01:00
## Licenses
- **Binaries**: AGPL-3.0
- Core and modules
- **Libraries**: MPL-2.0
- Parser and utils