Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/textual_dev/tools/diagnose.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def _guess_term() -> str:
The best guess at the name of the terminal.
"""

# First obvious place to look is in $TERM_PROGRAM.
term_program = os.environ.get("TERM_PROGRAM")
# Look in a couple of generic locations for the name of the terminal.
term_program = os.environ.get("TERM_PROGRAM") or os.environ.get("TERMINAL_NAME")

if term_program is None:
# Seems we couldn't get it that way. Let's check for some of the
Expand All @@ -87,11 +87,23 @@ def _guess_term() -> str:

else:
# See if we can pull out some sort of version information too.
term_version = os.environ.get("TERM_PROGRAM_VERSION")
term_version = os.environ.get("TERM_PROGRAM_VERSION") or os.environ.get(
"TERMINAL_VERSION_STRING"
)
if term_version is not None:
term_program = f"{term_program} ({term_version})"

return "*Unknown*" if term_program is None else term_program
# Seems we can't work this out.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see these changes in this commit but I don’t see them in the final “changes” of the PR. What am I missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that I was working on a fork that I forgot to sync, was confused as to why the screen detection wasn't in the code, added it to this, then realised what was going on, did a sync, a merge, and then it had the effect of nullifying that change.

if term_program is None:
term_program = "*Unknown*"

# Check for running under screen. As you look at this you might think
# "what about tmux too?" -- good point; but we'll be picking up tmux as
# the terminal type, because of how it takes over TERM_PROGRAM.
if "STY" in os.environ:
term_program += " (inside screen)"

return term_program


def _env(var_name: str) -> str:
Expand Down