diff --git a/tests/test_utils.py b/tests/test_utils.py index 99c2246..b51ec39 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -53,7 +53,7 @@ def get_aliases(mocker): @pytest.mark.usefixtures('no_memoize', 'get_aliases') -def test_get_all_callables(): +def test_get_all_executables(): all_callables = get_all_executables() assert 'vim' in all_callables assert 'fsck' in all_callables diff --git a/thefuck/utils.py b/thefuck/utils.py index 2736e85..57fe2f5 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -10,6 +10,7 @@ import pickle import re from pathlib import Path +import pkg_resources import six @@ -94,11 +95,17 @@ def get_all_executables(): return fallback tf_alias = thefuck_alias() - return [exe.name + tf_entry_points = pkg_resources.require('thefuck')[0]\ + .get_entry_map()\ + .get('console_scripts', {})\ + .keys() + bins = [exe.name for path in os.environ.get('PATH', '').split(':') for exe in _safe(lambda: list(Path(path).iterdir()), []) - if not _safe(exe.is_dir, True)] + [ - alias for alias in get_aliases() if alias != tf_alias] + if not _safe(exe.is_dir, True) + and exe.name not in tf_entry_points] + aliases = [alias for alias in get_aliases() if alias != tf_alias] + return bins + aliases def replace_argument(script, from_, to):