#475: Try to use already used executable in no_command
This commit is contained in:
@@ -269,3 +269,24 @@ def get_installation_info():
|
||||
|
||||
def get_alias():
|
||||
return os.environ.get('TF_ALIAS', 'fuck')
|
||||
|
||||
|
||||
@memoize
|
||||
def get_valid_history_without_current(command):
|
||||
def _not_corrected(history, tf_alias):
|
||||
"""Returns all lines from history except that comes before `fuck`."""
|
||||
previous = None
|
||||
for line in history:
|
||||
if previous is not None and line != tf_alias:
|
||||
yield previous
|
||||
previous = line
|
||||
if history:
|
||||
yield history[-1]
|
||||
|
||||
from thefuck.shells import shell
|
||||
history = shell.get_history()
|
||||
tf_alias = get_alias()
|
||||
executables = get_all_executables()
|
||||
return [line for line in _not_corrected(history, tf_alias)
|
||||
if not line.startswith(tf_alias) and not line == command.script
|
||||
and line.split(' ')[0] in executables]
|
||||
|
||||
Reference in New Issue
Block a user