workshop rework
This commit is contained in:
1 parent
a3a80dfa16
commit
fb39e290c0
115 files changed
+1865
-497
No files matched your search
@@ -0,0 +1,22 @@
|
||||
"""OSC 8 file links, with plain paths for unsupported or redirected consoles."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
|
||||
def file_link(path, mode="auto", stream=None):
|
||||
target = Path(path).resolve()
|
||||
stream = sys.stdout if stream is None else stream
|
||||
supported = (
|
||||
stream.isatty()
|
||||
and os.environ.get("TERM") != "dumb"
|
||||
and (
|
||||
os.environ.get("WT_SESSION")
|
||||
or os.environ.get("TERM_PROGRAM") in {"vscode", "iTerm.app", "WezTerm", "ghostty"}
|
||||
or os.environ.get("VTE_VERSION")
|
||||
or os.environ.get("KONSOLE_VERSION")
|
||||
)
|
||||
)
|
||||
if mode == "always" or (mode == "auto" and supported):
|
||||
return f"\033]8;;{target.as_uri()}\033\\{target}\033]8;;\033\\"
|
||||
return str(target)
|
||||
Reference in new issue
Block a user