mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-19 00:58:56 +00:00
This fixes #50 and #98. ```bash $ cd foo/bar/baz cd: foo: No such file or directory $ fuck mkdir -p foo/bar/baz && cd foo/bar/baz ``` Added matchers for both Bash and sh error messages. Depending on your default shell, the messages might be slightly different.
15 lines
398 B
Python
15 lines
398 B
Python
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)
|