mirror of
https://github.com/nvbn/thefuck.git
synced 2025-10-08 12:53:58 +01:00
#102 Update readme
This commit is contained in:
@@ -162,6 +162,9 @@ For adding your own rule you should create `your-rule-name.py`
|
|||||||
in `~/.thefuck/rules`. Rule should contain two functions:
|
in `~/.thefuck/rules`. Rule should contain two functions:
|
||||||
`match(command: Command, settings: Settings) -> bool`
|
`match(command: Command, settings: Settings) -> bool`
|
||||||
and `get_new_command(command: Command, settings: Settings) -> str`.
|
and `get_new_command(command: Command, settings: Settings) -> str`.
|
||||||
|
Also the rule can contain optional function
|
||||||
|
`side_effect(command: Command, settings: Settings) -> None` and
|
||||||
|
optional boolean `enabled_by_default`
|
||||||
|
|
||||||
`Command` has three attributes: `script`, `stdout` and `stderr`.
|
`Command` has three attributes: `script`, `stdout` and `stderr`.
|
||||||
|
|
||||||
@@ -177,6 +180,12 @@ def match(command, settings):
|
|||||||
|
|
||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
return 'sudo {}'.format(command.script)
|
return 'sudo {}'.format(command.script)
|
||||||
|
|
||||||
|
# Optional:
|
||||||
|
enabled_by_default = True
|
||||||
|
|
||||||
|
def side_effect(command, settings):
|
||||||
|
subprocess.call('chmod 777 .', shell=True)
|
||||||
```
|
```
|
||||||
|
|
||||||
[More examples of rules](https://github.com/nvbn/thefuck/tree/master/thefuck/rules),
|
[More examples of rules](https://github.com/nvbn/thefuck/tree/master/thefuck/rules),
|
||||||
|
Reference in New Issue
Block a user