thefuck icon indicating copy to clipboard operation
thefuck copied to clipboard

Upper to lower case

Open nkakonas opened this issue 2 years ago • 5 comments

This rule convert the upper case letters of the command to lower case, only if all the letters of the command are uppercase (which is the most common mistake with upper and lower case letters). For example, if I type $ LS an error will occur. So I will type $ fuck ls [enter/↑/↓/ctrl+c]

nkakonas avatar May 07 '22 23:05 nkakonas

This one is a nice idea, but what about LS _A ?

And, a watching point : env vars are upper case, and comes before the command :

FLASK_APP=app python -m flask run

(I don't know, if either of this points are relevant, just thinking :thinking: )

Rom1deTroyes avatar May 08 '22 07:05 Rom1deTroyes

Yes you are right, I will try to fix those too. I'm open to suggestions. Thanks!

nkakonas avatar May 08 '22 10:05 nkakonas

@scorphus I converted this pull request to a draft, so I can improve it as @Rom1deTroyes mentioned. I have already write some code. Do you think is a good idea?

nkakonas avatar May 08 '22 16:05 nkakonas

I have a much simpler implementation as part of my local rules, which seems to catch most of my issues, and doesnt try to do too much:

from thefuck.utils import get_all_executables, which


def match(command):
    return (command.script.isupper()
    	    and not which(command.script_parts[0])
            and ('not found' in command.output
                 or 'is not recognized as' in command.output)
            and (command.script_parts[0].lower() in get_all_executables()))


def get_new_command(cmd):
    return cmd.script.lower()


requires_output = False
priority = 100

djh82 avatar May 18 '22 14:05 djh82

Thank you very much for reviewing! I followed your instructions.

nkakonas avatar May 19 '22 21:05 nkakonas