1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-19 00:58:56 +00:00
thefuck/thefuck/rules/cd_mkdir.py

24 lines
693 B
Python

import re
from thefuck.utils import for_app
from thefuck.specific.sudo import sudo_support
from thefuck.shells import shell
import os
@sudo_support
@for_app('cd')
def match(command):
return (
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(),
'cannot find the path' in command.output.lower(),
'cannot find path' in command.output.lower()
)))
@sudo_support
def get_new_command(command):
repl = 'mkdir -p \\1; cd \\1'
return re.sub(r'^cd (.*)', repl, command.script)