Projects STRLCPY thefuck Commits 0fcc35c2
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    README.md
    skipped 140 lines
    141 141   
    142 142  * `cargo` – runs `cargo build` instead of `cargo`;
    143 143  * `cargo_no_command` – fixes wrongs commands like `cargo buid`;
    144  -* `cd_correction` – spellchecks and correct failed cd commands;
    145  -* `cd_mkdir` – creates directories before cd'ing into them;
     144 +* `cd_correction` – spellchecks and correct failed cd commands, when it's not possible
     145 +creates directories before cd'ing into them;
    146 146  * `cd_parent` – changes `cd..` to `cd ..`;
    147 147  * `composer_not_command` – fixes composer command name;
    148 148  * `cp_omitting_directory` – adds `-a` when you `cp` directory;
    skipped 200 lines
  • ■ ■ ■ ■
    tests/rules/test_cd_mkdir.py tests/rules/test_cd_correct.py
    1 1  import pytest
    2  -from thefuck.rules.cd_mkdir import match, get_new_command
     2 +from thefuck.rules.cd_correction import match, get_new_command
    3 3  from tests.utils import Command
    4 4   
    5 5   
    skipped 21 lines
  • ■ ■ ■ ■ ■ ■
    thefuck/rules/cd_correction.py
    skipped 1 lines
    2 2   
    3 3  import os
    4 4  from difflib import get_close_matches
     5 +import re
    5 6  from thefuck.specific.sudo import sudo_support
    6  -from thefuck.rules import cd_mkdir
    7 7  from thefuck.utils import for_app
     8 +from thefuck import shells
    8 9   
    9 10  __author__ = "mmussomele"
    10 11   
    skipped 32 lines
    43 44   elif directory == "..":
    44 45   cwd = os.path.split(cwd)[0]
    45 46   continue
    46  - best_matches = get_close_matches(directory, _get_sub_dirs(cwd), cutoff=MAX_ALLOWED_DIFF)
     47 + best_matches = get_close_matches(
     48 + directory, _get_sub_dirs(cwd), cutoff=MAX_ALLOWED_DIFF)
    47 49   if best_matches:
    48 50   cwd = os.path.join(cwd, best_matches[0])
    49 51   else:
    50  - return cd_mkdir.get_new_command(command)
     52 + repl = shells.and_('mkdir -p \\1', 'cd \\1')
     53 + return re.sub(r'^cd (.*)', repl, command.script)
    51 54   return 'cd "{0}"'.format(cwd)
    52 55   
    53 56   
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    thefuck/rules/cd_mkdir.py
    1  -import re
    2  -from thefuck import shells
    3  -from thefuck.utils import for_app
    4  -from thefuck.specific.sudo import sudo_support
    5  - 
    6  - 
    7  -@sudo_support
    8  -@for_app('cd')
    9  -def match(command):
    10  - return (('no such file or directory' in command.stderr.lower()
    11  - or 'cd: can\'t cd to' in command.stderr.lower()))
    12  - 
    13  - 
    14  -@sudo_support
    15  -def get_new_command(command):
    16  - repl = shells.and_('mkdir -p \\1', 'cd \\1')
    17  - return re.sub(r'^cd (.*)', repl, command.script)
    18  - 
Please wait...
Page is in error, reload to recover