diff --git a/thefuck/rules/cd_mkdir.py b/thefuck/rules/cd_mkdir.py index 363b92d4..6eb9a935 100644 --- a/thefuck/rules/cd_mkdir.py +++ b/thefuck/rules/cd_mkdir.py @@ -11,7 +11,9 @@ def match(command): command.script.startswith('cd ') and any(( 'no such file or directory' in command.output.lower(), 'cd: can\'t cd to' in command.output.lower(), - 'does not exist' in command.output.lower() + 'does not exist' in command.output.lower(), + 'cannot find the path' in command.output.lower(), + 'cannot find path' in command.output.lower() ))) diff --git a/thefuck/rules/chdir.py b/thefuck/rules/chdir.py new file mode 100644 index 00000000..819c179b --- /dev/null +++ b/thefuck/rules/chdir.py @@ -0,0 +1,20 @@ +import re +from thefuck.utils import for_app +from thefuck.specific.sudo import sudo_support +from thefuck.shells import shell + + +@sudo_support +@for_app('chdir') +def match(command): + return ( + command.script.startswith('chdir ') and any(( + 'cannot find the path' in command.output.lower(), + ))) + + +@sudo_support +def get_new_command(command): + repl = shell.and_('mkdir -p \\1', 'chdir \\1') + return re.sub(r'^chdir (.*)', repl, command.script) +