diff --git a/thefuck/rules/chdir.py b/thefuck/rules/chdir.py index 28da9290..1e56d203 100644 --- a/thefuck/rules/chdir.py +++ b/thefuck/rules/chdir.py @@ -12,10 +12,15 @@ def match(command): 'cannot find the path' in command.output.lower(), 'cannot find path' in command.output.lower(), 'can\'t cd to' in command.output.lower() - ))) + ))) @sudo_support def get_new_command(command): - repl = 'mkdir -p \\1; chdir \\1' - return re.sub(r'^chdir(.*)', repl, command.script) + shell_name = shell.info() + if shell_name == 'pwsh' or shell_name == 'powershell': + new_command = ('mkdir -p \\1' + '; chdir\\1') + return re.sub(r'^chdir(.*)', new_command, command.script) + else: + repl = ('mkdir -p \\1; chdir \\1') + return re.sub(r'^chdir(.*)', repl, command.script)