Only hyperlink when stdout is a tty

This commit is contained in:
Kovid Goyal 2022-08-19 14:05:53 +05:30
parent a59e1adee1
commit 033950dae9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -156,7 +156,9 @@ role_map['envvar'] = role_map['env']
def hyperlink_for_url(url: str, text: str) -> str:
return f'\x1b]8;;{url}\x1b\\\x1b[4:3;58:5:4m{text}\x1b[4:0;59m\x1b]8;;\x1b\\'
if sys.stdout.isatty():
return f'\x1b]8;;{url}\x1b\\\x1b[4:3;58:5:4m{text}\x1b[4:0;59m\x1b]8;;\x1b\\'
return text
@role