aboutsummaryrefslogtreecommitdiff
path: root/src/term
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-05-05 10:10:45 -0700
committerFranck Cuny <franck@fcuny.net>2024-05-06 19:29:12 -0700
commit68e0d456170baa8a602035bcc52e5b7b4388912a (patch)
treee31e2218752b7101213f574a236f878dde00a3d7 /src/term
parentlint and fmt (diff)
downloadinfra-68e0d456170baa8a602035bcc52e5b7b4388912a.tar.gz
add some utility functions
Diffstat (limited to 'src/term')
-rw-r--r--src/term/link.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/term/link.py b/src/term/link.py
new file mode 100644
index 0000000..cd75b16
--- /dev/null
+++ b/src/term/link.py
@@ -0,0 +1,9 @@
+def link(text: str, url: str) -> str:
+ """Link returns a formatted string that represents a hyperlink.
+ The hyperlink is created using the escape sequence for terminal emulators.
+ The text parameter represents the visible text of the hyperlink,
+ and the url parameter represents the URL that the hyperlink points to.
+For more information on the escape sequence, refer to:
+ https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#the-escape-sequence
+ """
+ return f""\x1b]8;;{url}\x07{text}\x1b]8;;\x07\u001b[0m""