diff --git a/thefuck/shells/__init__.py b/thefuck/shells/__init__.py index 414b8ee7..4a75b826 100644 --- a/thefuck/shells/__init__.py +++ b/thefuck/shells/__init__.py @@ -18,11 +18,26 @@ shells = {'bash': Bash, def _get_shell(): - try: - shell_name = Process(os.getpid()).parent().name() - except TypeError: - shell_name = Process(os.getpid()).parent.name - return shells.get(shell_name, Generic)() + proc = Process(os.getpid()) + + while (proc is not None): + name = None + try: + name = proc.name() + except TypeError: + name = proc.name + + name = os.path.splitext(name)[0] + + if name in shells: + return shells[name]() + + try: + proc = proc.parent() + except TypeError: + proc = proc.parent + + return Generic() shell = _get_shell()