mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
#N/A: Get shell from env if possible
This commit is contained in:
parent
50dd4b8f54
commit
1cae91b649
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user