From 17819928917c4a4f6204193d4ac5866d4ca7f2e5 Mon Sep 17 00:00:00 2001 From: FireFragment <55660550+FireFragment@users.noreply.github.com> Date: Mon, 17 Apr 2023 15:56:05 +0200 Subject: [PATCH 1/2] Add cd_quotes rule This rule fixes forgotten quotes around directory name, when using cd. It has priority 900 to override the `cd_mkdir` rule. --- thefuck/rules/cd_quotes.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 thefuck/rules/cd_quotes.py 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 From b8fc960d40b111da406f83e8f4cf2722abd2c7ed Mon Sep 17 00:00:00 2001 From: FireFragment <55660550+FireFragment@users.noreply.github.com> Date: Mon, 17 Apr 2023 16:08:57 +0200 Subject: [PATCH 2/2] Add `cd_quotes` to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3ea406f..2afe677 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;