Command suggestions, command-not-found and thefuck replacement written in Rust https://codeberg.org/iff/pay-respects
Find a file
2023-07-30 20:08:31 +02:00
rule_parser quality of life: make all pattern lowcase 2023-07-30 19:02:21 +02:00
rules fix: sudo pattern 2023-07-30 19:50:22 +02:00
src fix: clippy fixes caused the lose of color 2023-07-30 18:58:14 +02:00
.gitignore init 2023-07-30 18:40:18 +02:00
.rustfmt.toml init 2023-07-30 18:40:18 +02:00
Cargo.toml init 2023-07-30 18:40:18 +02:00
LICENSE add LICENSE 2023-07-30 20:08:31 +02:00
README.md add: Rule explanation in README 2023-07-30 20:08:28 +02:00

Pay Respect

Typed a wrong command? Pay Respect will try to correct your wrong console command simply by pressing F!

How to Pay Respect

The binary is named pay-respect, by adding an alias to your shell configuration:

alias f="pay_respect"

You can now press F to Pay Respect!

Rule Files

Rule files are parsed at compilation. What actually gets compiled is a HashMap that contains patterns and suggestions for a specific command.

Syntax of a rule file (placed under rules):

# this field should be the name of the command
command = "world"

# you can add as much section of like this as you like
[[match_output]]
# the suggestion of this section will be used for the following patterns of the command output
pattern = [
	"pattern 1",
	"pattern 2",
]
# this will keep the change the second argument to `fix`
suggest = "{{command[0]}} fix {{command[2:]}}"

[[match_output]]
pattern = [
	"pattern 1",
]
# this will add a `sudo` before the command, without touching the rest
suggest = "sudo {{command}}"

The placeholder is evaluated as following:

  • {{command}}: All the command without any modification
  • {{command[1]}}: The first argument of the command (the command itself has index of 0)
  • {{command[2:5]}}: The second to fifth arguments. If any of the side is not specified, them it defaults to the start (if it is left) or the end (if it is right).

Current Progress

Currently, only correction to sudo permission is implemented.