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

#658: Ensure that history isn't empty in autoconfiguration

This commit is contained in:
Vladimir Iakovlev 2017-08-16 11:26:43 +02:00
parent 71a5182b9a
commit e31124335f

View File

@ -40,6 +40,15 @@ def _record_first_run():
json.dump(info, tracker)
def _get_previous_command():
history = shell.get_history()
if history:
return history[-1]
else:
return None
def _is_second_run():
"""Returns `True` when we know that `fuck` called second time."""
tracker_path = _get_not_configured_usage_tracker_path()
@ -56,7 +65,7 @@ def _is_second_run():
if not (isinstance(info, dict) and info.get('pid') == current_pid):
return False
return (shell.get_history()[-1] == 'fuck' or
return (_get_previous_command() == 'fuck' or
time.time() - info.get('time', 0) < const.CONFIGURATION_TIMEOUT)