1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-27 13:09:00 +00:00
thefuck/thefuck/rules/cd_mkdir.py
2016-01-29 13:09:40 +03:00

19 lines
539 B
Python

import re
from thefuck.utils import for_app
from thefuck.specific.sudo import sudo_support
from thefuck.shells import shell
@sudo_support
@for_app('cd')
def match(command):
return (('no such file or directory' in command.stderr.lower()
or 'cd: can\'t cd to' in command.stderr.lower()
or 'the system cannot find the path specified.' in command.stderr.lower()))
@sudo_support
def get_new_command(command):
repl = shell.and_('mkdir -p \\1', 'cd \\1')
return re.sub(r'^cd (.*)', repl, command.script)