Files
thefuck/thefuck/rules/cd_mkdir.py
T
Pablo Santiago Blum de Aguiar 3d0d4be4a9 refact(shells): add and_ method to assemble expressions involving AND
Signed-off-by: Pablo Santiago Blum de Aguiar <scorphus@gmail.com>
2015-05-16 11:52:50 -03:00

17 lines
454 B
Python

import re
from thefuck import shells
from thefuck.utils import sudo_support
@sudo_support
def match(command, settings):
return (command.script.startswith('cd ')
and ('no such file or directory' in command.stderr.lower()
or 'cd: can\'t cd to' in command.stderr.lower()))
@sudo_support
def get_new_command(command, settings):
repl = shells.and_('mkdir -p \\1', 'cd \\1')
return re.sub(r'^cd (.*)', repl, command.script)