mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-22 12:58:33 +00:00
Merge pull request #432 from nvbn/422-not-alter-history
#422: Add `alter_history` settings option
This commit is contained in:
commit
3c3d17e0ea
@ -283,6 +283,7 @@ The Fuck has a few settings parameters which can be changed in `$XDG_CONFIG_HOME
|
|||||||
* `priority` – dict with rules priorities, rule with lower `priority` will be matched first;
|
* `priority` – dict with rules priorities, rule with lower `priority` will be matched first;
|
||||||
* `debug` – enables debug output, by default `False`;
|
* `debug` – enables debug output, by default `False`;
|
||||||
* `history_limit` – numeric value of how many history commands will be scanned, like `2000`;
|
* `history_limit` – numeric value of how many history commands will be scanned, like `2000`;
|
||||||
|
* `alter_history` – push fixed command to history, by default `True`.
|
||||||
|
|
||||||
Example of `settings.py`:
|
Example of `settings.py`:
|
||||||
|
|
||||||
@ -306,7 +307,8 @@ Or via environment variables:
|
|||||||
* `THEFUCK_PRIORITY` – priority of the rules, like `no_command=9999:apt_get=100`,
|
* `THEFUCK_PRIORITY` – priority of the rules, like `no_command=9999:apt_get=100`,
|
||||||
rule with lower `priority` will be matched first;
|
rule with lower `priority` will be matched first;
|
||||||
* `THEFUCK_DEBUG` – enables debug output, `true/false`;
|
* `THEFUCK_DEBUG` – enables debug output, `true/false`;
|
||||||
* `THEFUCK_HISTORY_LIMIT` – how many history commands will be scanned, like `2000`.
|
* `THEFUCK_HISTORY_LIMIT` – how many history commands will be scanned, like `2000`;
|
||||||
|
* `THEFUCK_ALTER_HISTORY` – push fixed command to history `true/false`.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ DEFAULT_SETTINGS = {'rules': DEFAULT_RULES,
|
|||||||
'debug': False,
|
'debug': False,
|
||||||
'priority': {},
|
'priority': {},
|
||||||
'history_limit': None,
|
'history_limit': None,
|
||||||
|
'alter_history': True,
|
||||||
'env': {'LC_ALL': 'C', 'LANG': 'C', 'GIT_TRACE': '1'}}
|
'env': {'LC_ALL': 'C', 'LANG': 'C', 'GIT_TRACE': '1'}}
|
||||||
|
|
||||||
ENV_TO_ATTR = {'THEFUCK_RULES': 'rules',
|
ENV_TO_ATTR = {'THEFUCK_RULES': 'rules',
|
||||||
@ -24,9 +25,10 @@ ENV_TO_ATTR = {'THEFUCK_RULES': 'rules',
|
|||||||
'THEFUCK_WAIT_COMMAND': 'wait_command',
|
'THEFUCK_WAIT_COMMAND': 'wait_command',
|
||||||
'THEFUCK_REQUIRE_CONFIRMATION': 'require_confirmation',
|
'THEFUCK_REQUIRE_CONFIRMATION': 'require_confirmation',
|
||||||
'THEFUCK_NO_COLORS': 'no_colors',
|
'THEFUCK_NO_COLORS': 'no_colors',
|
||||||
'THEFUCK_PRIORITY': 'priority',
|
|
||||||
'THEFUCK_DEBUG': 'debug',
|
'THEFUCK_DEBUG': 'debug',
|
||||||
'THEFUCK_HISTORY_LIMIT': 'history_limit'}
|
'THEFUCK_PRIORITY': 'priority',
|
||||||
|
'THEFUCK_HISTORY_LIMIT': 'history_limit',
|
||||||
|
'THEFUCK_ALTER_HISTORY': 'alter_history'}
|
||||||
|
|
||||||
SETTINGS_HEADER = u"""# The Fuck settings file
|
SETTINGS_HEADER = u"""# The Fuck settings file
|
||||||
#
|
#
|
||||||
@ -126,7 +128,8 @@ class Settings(dict):
|
|||||||
return dict(self._priority_from_env(val))
|
return dict(self._priority_from_env(val))
|
||||||
elif attr == 'wait_command':
|
elif attr == 'wait_command':
|
||||||
return int(val)
|
return int(val)
|
||||||
elif attr in ('require_confirmation', 'no_colors', 'debug'):
|
elif attr in ('require_confirmation', 'no_colors', 'debug',
|
||||||
|
'alter_history'):
|
||||||
return val.lower() == 'true'
|
return val.lower() == 'true'
|
||||||
elif attr == 'history_limit':
|
elif attr == 'history_limit':
|
||||||
return int(val)
|
return int(val)
|
||||||
|
@ -278,6 +278,7 @@ class CorrectedCommand(object):
|
|||||||
"""
|
"""
|
||||||
if self.side_effect:
|
if self.side_effect:
|
||||||
compatibility_call(self.side_effect, old_cmd, self.script)
|
compatibility_call(self.side_effect, old_cmd, self.script)
|
||||||
|
if settings.alter_history:
|
||||||
shells.put_to_history(self.script)
|
shells.put_to_history(self.script)
|
||||||
# This depends on correct setting of PYTHONIOENCODING by the alias:
|
# This depends on correct setting of PYTHONIOENCODING by the alias:
|
||||||
print(self.script)
|
print(self.script)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user