The Fuck 3.32 using Python 3.8.10 and Bash 5.0.17(1)-release
Your system (Debian 7, ArchLinux, Windows, etc.):
Linux version 5.15.133.1-microsoft-standard-WSL2 (root@1c602f52c2e4) (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37) #1 SMP Thu Oct 5 21:02:42 UTC 2023
How to reproduce the bug:
1. Enter a command with a typo in the "nvm" command, such as "nvvm", "nvmm"
2. Observe that the suggestion recommends the command "nvm."
(Currently, only 'nm' is recommended, but I want to make 'nvm' come out as well.)
The output of The Fuck with THEFUCK_DEBUG=true exported (typically execute export THEFUCK_DEBUG=true in your shell before The Fuck) :
N/A
If the bug only appears with a specific application, the output of that application and its version :
N/A
Anything else you think is relevant :
N/A
Additional Information:
I attempted to add a rule to correct the typo in the "nvm" command by creating a new rule file nvm.py in the rule directory. Here are the three attempts:
1.
import re
def match(command):
return (
"not found" in command.output
and any(re.search(r"\bnvm\b", arg) for arg in command.script_parts)
)
def get_new_command(command):
return "nvm " + " ".join(command.script_parts[1:])
if closest_match:
new_command = command.script.replace(closest_match, 'nvm')
return new_command
return ['nvm']
However, none of these rules seem to be recognized by The Fuck. I would appreciate any guidance or suggestions on how to correctly implement the rule for correcting the typo in the "nvm" command. Thank you!
The output of
thefuck --version
:Your system (Debian 7, ArchLinux, Windows, etc.):
How to reproduce the bug:
The output of The Fuck with
THEFUCK_DEBUG=true
exported (typically executeexport THEFUCK_DEBUG=true
in your shell before The Fuck) :If the bug only appears with a specific application, the output of that application and its version :
Anything else you think is relevant :
Additional Information:
I attempted to add a rule to correct the typo in the "nvm" command by creating a new rule file
nvm.py
in therule
directory. Here are the three attempts:1.
def match(command): if SequenceMatcher(None, command.script_parts[0], "nvm").ratio() > 0.6: return 1 else: return 0
def get_new_command(command): return "nvm"
from thefuck.utils import for_app, get_closest
@for_app('nvm') def match(command): return 'command not found' in command.stderr
def get_new_command(command): closest_match = get_closest(command.script, ['nvm'], cutoff=0.8)