Skip to content

Commit

Permalink
feat(pwsh): render hyperlink for theme name
Browse files Browse the repository at this point in the history
render hyperlink for theme name and themes location in Get-PoshThemes
bold attribute removed since it's not really working in windows
terminal(microsoft/terminal#109)
  • Loading branch information
lnu authored and JanDeDobbeleer committed Oct 18, 2021
1 parent e6cb3a5 commit 410fb82
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions packages/powershell/oh-my-posh/oh-my-posh.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ function Set-PoshPrompt {
(& $poshCommand --init --shell=pwsh --config="$config") | Invoke-Expression
}

<#
.SYNOPSIS
Returns an ansi formatted hyperlink
if name not set, uri is used as the name of the hyperlink
.EXAMPLE
Get-Hyperlink
#>
function Get-Hyperlink {
param(
[Parameter(Mandatory)]
[string]$uri,
[string]$name
)
$esc = [char]27
if ("" -eq $name) {
$name = $uri
}
if ($env:WSL_DISTRO_NAME -ne $null){
# wsl conversion if needed
$uri= &wslpath -m $uri
}
return "$esc]8;;file://$uri$esc\$name$esc]8;;$esc\"
}

<#
.SYNOPSIS
Display a preview or a list of installed themes.
Expand All @@ -91,7 +115,6 @@ function Get-PoshThemes() {
[Parameter(Mandatory = $false, HelpMessage = "List themes path")]
$list
)
$esc = [char]27
$consoleWidth = $Host.UI.RawUI.WindowSize.Width
$logo = @'
__ _____ _ ___ ___ ______ _ __
Expand All @@ -112,15 +135,15 @@ function Get-PoshThemes() {
else {
$poshCommand = Get-PoshCommand
$themes | ForEach-Object -Process {
Write-Host "Theme: $esc[1m$($_.BaseName.Replace('.omp', ''))$esc[0m"
Write-Host "Theme: $(Get-Hyperlink -uri $_.fullname -name $_.BaseName.Replace('.omp', ''))"
Write-Host ""
& $poshCommand -config $($_.FullName) -pwd $PWD
Write-Host ""
}
}
Write-Host ("-" * $consoleWidth)
Write-Host ""
Write-Host "Themes location: $PSScriptRoot\themes"
Write-Host "Themes location: $(Get-Hyperlink -uri "$PSScriptRoot/themes")"
Write-Host ""
Write-Host "To change your theme, use the Set-PoshPrompt command. Example:"
Write-Host " Set-PoshPrompt -Theme jandedobbeleer"
Expand Down

0 comments on commit 410fb82

Please sign in to comment.