diff --git a/README.md b/README.md index f18fafb0..620d2360 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,10 @@ using matched rule and run it. Rules enabled by default: * `sudo` – prepends `sudo` to previous command if it failed because of permissions; * `switch_layout` – switches command from your local layout to en. +Bundled, but not enabled by default: + +* `rm_root` – adds `--no-preserve-root` to `rm -rf /` command. + ## Creating your own rules For adding your own rule you should create `your-rule-name.py` diff --git a/thefuck/main.py b/thefuck/main.py index a6c24ee5..32c1c7c8 100644 --- a/thefuck/main.py +++ b/thefuck/main.py @@ -153,7 +153,8 @@ def main(): logs.failed("Can't fuck twice", settings) return - rules = get_rules(user_dir, settings) + rules = list(get_rules(user_dir, settings)) + sys.stderr.write(str([r.name for r in rules]) + '\n') matched_rule = get_matched_rule(command, rules, settings) if matched_rule: run_rule(matched_rule, command, settings) diff --git a/thefuck/rules/rm_root.py b/thefuck/rules/rm_root.py index 853ce847..fc75332d 100644 --- a/thefuck/rules/rm_root.py +++ b/thefuck/rules/rm_root.py @@ -1,5 +1,8 @@ +enabled_by_default = False + + def match(command, settings): - return ('/' in command.script.split() + return ({'rm', '/'}.issubset(command.script.split()) and '--no-preserve-root' not in command.script and '--no-preserve-root' in command.stderr)