mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 06:34:09 +00:00 
			
		
		
		
	Merge branch 'debug' of git://github.com/lovedboy/thefuck into lovedboy-debug
This commit is contained in:
		| @@ -303,7 +303,8 @@ Or via environment variables: | |||||||
| * `THEFUCK_NO_COLORS` – disable colored output, `true/false`; | * `THEFUCK_NO_COLORS` – disable colored output, `true/false`; | ||||||
| * `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`. | ||||||
|  |  | ||||||
| For example: | For example: | ||||||
|  |  | ||||||
| @@ -314,6 +315,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 | ||||||
|   | |||||||
| @@ -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', | ||||||
| @@ -24,7 +25,8 @@ ENV_TO_ATTR = {'THEFUCK_RULES': 'rules', | |||||||
|                'THEFUCK_REQUIRE_CONFIRMATION': 'require_confirmation', |                'THEFUCK_REQUIRE_CONFIRMATION': 'require_confirmation', | ||||||
|                'THEFUCK_NO_COLORS': 'no_colors', |                'THEFUCK_NO_COLORS': 'no_colors', | ||||||
|                'THEFUCK_PRIORITY': 'priority', |                'THEFUCK_PRIORITY': 'priority', | ||||||
|                'THEFUCK_DEBUG': 'debug'} |                'THEFUCK_DEBUG': 'debug', | ||||||
|  |                'THEFUCK_HISTORY_LIMIT': 'history_limit'} | ||||||
|  |  | ||||||
| SETTINGS_HEADER = u"""# The Fuck settings file | SETTINGS_HEADER = u"""# The Fuck settings file | ||||||
| # | # | ||||||
|   | |||||||
| @@ -12,6 +12,7 @@ import os | |||||||
| import shlex | import shlex | ||||||
| import six | import six | ||||||
| from .utils import DEVNULL, memoize, cache | from .utils import DEVNULL, memoize, cache | ||||||
|  | from .conf import settings | ||||||
|  |  | ||||||
|  |  | ||||||
| class Generic(object): | class Generic(object): | ||||||
| @@ -61,10 +62,16 @@ class Generic(object): | |||||||
|  |  | ||||||
|     def get_history(self): |     def get_history(self): | ||||||
|         """Returns list of history entries.""" |         """Returns list of history entries.""" | ||||||
|  |         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): | ||||||
|             with io.open(history_file_name, 'r', |             if tail_num is not None and tail_num.isdigit(): | ||||||
|                          encoding='utf-8', errors='ignore') as history: |                 _, f = os.popen2("tail -n {} {}".format(tail_num, history_file_name)) | ||||||
|  |                 _.close() | ||||||
|  |             else: | ||||||
|  |                 f = io.open(history_file_name, 'r', | ||||||
|  |                          encoding='utf-8', errors='ignore') | ||||||
|  |             with f as history: | ||||||
|                 for line in history: |                 for line in history: | ||||||
|                     prepared = self._script_from_history(line)\ |                     prepared = self._script_from_history(line)\ | ||||||
|                                    .strip() |                                    .strip() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user