1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-05 18:31:10 +01:00

history limit from settings

This commit is contained in:
lovedboy 2015-10-29 10:14:34 +08:00
parent 372e983459
commit b3a19fe439
3 changed files with 4 additions and 3 deletions

View File

@ -314,6 +314,7 @@ export THEFUCK_REQUIRE_CONFIRMATION='true'
export THEFUCK_WAIT_COMMAND=10 export THEFUCK_WAIT_COMMAND=10
export THEFUCK_NO_COLORS='false' export THEFUCK_NO_COLORS='false'
export THEFUCK_PRIORITY='no_command=9999:apt_get=100' export THEFUCK_PRIORITY='no_command=9999:apt_get=100'
export THEFUCK_HISTORY_LIMIT='2000'
``` ```
## Developing ## Developing

View File

@ -16,6 +16,7 @@ DEFAULT_SETTINGS = {'rules': DEFAULT_RULES,
'no_colors': False, 'no_colors': False,
'debug': False, 'debug': False,
'priority': {}, 'priority': {},
'history_limit': None,
'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',
@ -126,4 +127,3 @@ class Settings(dict):
settings = Settings(DEFAULT_SETTINGS) settings = Settings(DEFAULT_SETTINGS)
settings.init()

View File

@ -60,10 +60,10 @@ class Generic(object):
def get_history(self): def get_history(self):
"""Returns list of history entries.""" """Returns list of history entries."""
tail_num = settings.get("history_limit", None) tail_num = settings.history_limit
history_file_name = self._get_history_file_name() history_file_name = self._get_history_file_name()
if os.path.isfile(history_file_name): if os.path.isfile(history_file_name):
if tail_num is not None: if tail_num is not None and tail_num.isdigit():
_, f = os.popen2("tail -n {} {}".format(tail_num, history_file_name)) _, f = os.popen2("tail -n {} {}".format(tail_num, history_file_name))
_.close() _.close()
else: else: