Skip to content

Commit

Permalink
Slightly better xonsh check hack, fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Jan 26, 2023
1 parent 9e5c8ce commit 5b8a87d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tractor/_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def _cmdloop(self):
self.cmdloop()

@cached_property
def shname(self) -> str:
def shname(self) -> str | None:
'''
Attempt to return the login shell name with a special check for
the infamous `xonsh` since it seems to have some issues much
Expand All @@ -206,11 +206,18 @@ def shname(self) -> str:
'''
# SUPER HACKY and only really works if `xonsh` is not used
# before spawning further sub-shells..
xonsh_is_login_sh: bool = os.getenv('XONSH_LOGIN', default=False)
if xonsh_is_login_sh:
return 'xonsh'
shpath = os.getenv('SHELL', None)

return os.path.basename(os.getenv('SHELL'))
if shpath:
if (
os.getenv('XONSH_LOGIN', default=False)
or 'xonsh' in shpath
):
return 'xonsh'

return os.path.basename(shpath)

return None


@acm
Expand Down

0 comments on commit 5b8a87d

Please sign in to comment.