-
-
Save Jaykul/f46590c0f726dd6a4424ffa614ed1545 to your computer and use it in GitHub Desktop.
Powershell Function to create Terminal HyperLinks using ANSI Escape Sequences (Supported in Windows Terminal PREVIEW)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-Hyperlink { | |
<# | |
.SYNOPSIS | |
Creates a VT Hyperlink in a supported terminal such as Windows Terminal 1.4+ | |
.NOTES | |
There's a more powerful version of this, with color support and more, in PANSIES | |
.EXAMPLE | |
New-Hyperlink https://github.com/Jaykul/PANSIES PANSIES | |
Creates a hyperlink with the text PANSIES which links to the github project | |
#> | |
[Alias("Url")] | |
[CmdletBinding()] | |
param( | |
# The Uri the hyperlink should point to | |
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[string]$Uri, | |
# The text of the hyperlink (if not specified, defaults to the URI) | |
[ValidateNotNullOrEmpty()] | |
[Parameter(ValueFromRemainingArguments)] | |
[String]$InputObject = $Uri | |
) | |
$8 = [char]27 + "]8;;" | |
"$8{0}`a{1}$8`a" -f $Uri, $InputObject | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment