mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 06:38:32 +00:00
Follow the XDG Base Directory Specification
Namely, put configuration files in `~/.config`.
This commit is contained in:
parent
8be353941f
commit
23a75f6954
@ -209,7 +209,7 @@ Bundled, but not enabled by default:
|
||||
## Creating your own rules
|
||||
|
||||
For adding your own rule you should create `your-rule-name.py`
|
||||
in `~/.thefuck/rules`. The rule should contain two functions:
|
||||
in `~/.config/thefuck/rules`. The rule should contain two functions:
|
||||
|
||||
```python
|
||||
match(command: Command, settings: Settings) -> bool
|
||||
@ -221,7 +221,7 @@ and optional `enabled_by_default`, `requires_output` and `priority` variables.
|
||||
|
||||
`Command` has three attributes: `script`, `stdout` and `stderr`.
|
||||
|
||||
`Settings` is a special object filled with `~/.thefuck/settings.py` and values from env ([see more below](#settings)).
|
||||
`Settings` is a special object filled with `~/.config/thefuck/settings.py` and values from env ([see more below](#settings)).
|
||||
|
||||
Simple example of the rule for running script with `sudo`:
|
||||
|
||||
@ -250,7 +250,7 @@ requires_output = True
|
||||
|
||||
## Settings
|
||||
|
||||
The Fuck has a few settings parameters which can be changed in `~/.thefuck/settings.py`:
|
||||
The Fuck has a few settings parameters which can be changed in `~/.config/thefuck/settings.py`:
|
||||
|
||||
* `rules` – list of enabled rules, by default `thefuck.conf.DEFAULT_RULES`;
|
||||
* `require_confirmation` – requires confirmation before running new command, by default `True`;
|
||||
|
@ -41,7 +41,7 @@ ENV_TO_ATTR = {'THEFUCK_RULES': 'rules',
|
||||
'THEFUCK_DEBUG': 'debug'}
|
||||
|
||||
|
||||
SETTINGS_HEADER = u"""# ~/.thefuck/settings.py: The Fuck settings file
|
||||
SETTINGS_HEADER = u"""# ~/.config/thefuck/settings.py: The Fuck settings file
|
||||
#
|
||||
# The rules are defined as in the example bellow:
|
||||
#
|
||||
|
@ -13,8 +13,18 @@ from .ui import select_command
|
||||
|
||||
|
||||
def setup_user_dir():
|
||||
"""Returns user config dir, create it when it doesn't exist."""
|
||||
"""Returns user config dir, creates it when it doesn't exist.
|
||||
|
||||
Uses `~/.thefuck` if it exists, else `$XDG_CONFIG_HOME/thefuck` if it
|
||||
exists else `~/.config/thefuck`, which is created if it does not exist.
|
||||
"""
|
||||
user_dir = Path(expanduser('~/.thefuck'))
|
||||
|
||||
if not user_dir.is_dir():
|
||||
user_dir = Path(os.path.join(
|
||||
expanduser(os.getenv("XDG_CONFIG_HOME", "~/.config")), 'thefuck'
|
||||
))
|
||||
|
||||
rules_dir = user_dir.joinpath('rules')
|
||||
if not rules_dir.is_dir():
|
||||
rules_dir.mkdir(parents=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user