Merge pull request #120 from nwinkler/cd_mkdir

Added cd_mkdir rule
This commit is contained in:
Vladimir Iakovlev
2015-04-24 18:23:22 +02:00
3 changed files with 34 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
import re
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):
return re.sub(r'^cd (.*)', 'mkdir -p \\1 && cd \\1', command.script)