mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
#43 Add rm_root
as disabled by default rule
This commit is contained in:
parent
14ef5c7d1c
commit
fa4e4522b7
@ -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;
|
* `sudo` – prepends `sudo` to previous command if it failed because of permissions;
|
||||||
* `switch_layout` – switches command from your local layout to en.
|
* `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
|
## Creating your own rules
|
||||||
|
|
||||||
For adding your own rule you should create `your-rule-name.py`
|
For adding your own rule you should create `your-rule-name.py`
|
||||||
|
@ -153,7 +153,8 @@ def main():
|
|||||||
logs.failed("Can't fuck twice", settings)
|
logs.failed("Can't fuck twice", settings)
|
||||||
return
|
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)
|
matched_rule = get_matched_rule(command, rules, settings)
|
||||||
if matched_rule:
|
if matched_rule:
|
||||||
run_rule(matched_rule, command, settings)
|
run_rule(matched_rule, command, settings)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
enabled_by_default = False
|
||||||
|
|
||||||
|
|
||||||
def match(command, settings):
|
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' not in command.script
|
||||||
and '--no-preserve-root' in command.stderr)
|
and '--no-preserve-root' in command.stderr)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user