diff --git a/README.md b/README.md index 48b4b0f..7a91739 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,7 @@ following rules are enabled by default: * `cd_cs` – changes `cs` to `cd`; * `cd_mkdir` – creates directories before cd'ing into them; * `cd_parent` – changes `cd..` to `cd ..`; +* `cd_quotes` – adds quotes around directories with spaces in filenames when cd'ing into them; * `chmod_x` – add execution bit; * `choco_install` – append common suffixes for chocolatey packages; * `composer_not_command` – fixes composer command name; diff --git a/thefuck/rules/cd_quotes.py b/thefuck/rules/cd_quotes.py new file mode 100644 index 0000000..0718190 --- /dev/null +++ b/thefuck/rules/cd_quotes.py @@ -0,0 +1,10 @@ +def match(command): + return command.script_parts[0] == "cd" and command.script.count(" ") > 1 and (not("\"" in command.script)) + + +def get_new_command(command): + return 'cd \"{}\"'.format(' '.join(command.script_parts[1:])) + +enabled_by_default = True +priority = 900 +requires_output = False