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

#N/A: Get shell from env if possible

This commit is contained in:
Vladimir Iakovlev 2017-09-03 06:51:44 +02:00
parent 50dd4b8f54
commit 1cae91b649

View File

@ -19,7 +19,16 @@ shells = {'bash': Bash,
'powershell': Powershell}
def _get_shell():
def _get_shell_from_env():
path = os.environ.get('SHELL', '')
base_name = os.path.basename(path)
name = os.path.splitext(base_name)[0]
if name in shells:
return shells[name]()
def _get_shell_from_proc():
proc = Process(os.getpid())
while proc is not None and proc.pid > 0:
@ -41,4 +50,4 @@ def _get_shell():
return Generic()
shell = _get_shell()
shell = _get_shell_from_env() or _get_shell_from_proc()