Skip to content

Commit

Permalink
#658: Ensure that history isn't empty in autoconfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
nvbn committed Aug 16, 2017
1 parent 71a5182 commit e311243
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion thefuck/not_configured.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)


Expand Down

0 comments on commit e311243

Please sign in to comment.