mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
feat: -list parameter added to Get-PoshThemes
-list display the theme full path instead of the preview Themes location added at the end
This commit is contained in:
parent
930f9de114
commit
abe3d0990b
|
@ -42,7 +42,7 @@ Get-PoshThemes
|
||||||
The module installs all themes in the module folder. To find the actual files, you can use the following command:
|
The module installs all themes in the module folder. To find the actual files, you can use the following command:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
Get-ChildItem "$((Get-Module oh-my-posh).ModuleBase)/themes"
|
Get-PoshThemes -list
|
||||||
```
|
```
|
||||||
|
|
||||||
## Replace your existing prompt
|
## Replace your existing prompt
|
||||||
|
|
|
@ -70,7 +70,20 @@ function Set-PoshPrompt {
|
||||||
(& $poshCommand --init --shell=pwsh --config="$config") | Invoke-Expression
|
(& $poshCommand --init --shell=pwsh --config="$config") | Invoke-Expression
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-PoshThemes {
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Display a preview or a list of installed themes.
|
||||||
|
.EXAMPLE
|
||||||
|
Get-PoshThemes
|
||||||
|
.Example
|
||||||
|
Gest-PoshThemes -list
|
||||||
|
#>
|
||||||
|
function Get-PoshThemes() {
|
||||||
|
param(
|
||||||
|
[switch]
|
||||||
|
[Parameter(Mandatory = $false, HelpMessage = "List themes path")]
|
||||||
|
$list
|
||||||
|
)
|
||||||
$esc = [char]27
|
$esc = [char]27
|
||||||
$consoleWidth = $Host.UI.RawUI.WindowSize.Width
|
$consoleWidth = $Host.UI.RawUI.WindowSize.Width
|
||||||
$logo = @'
|
$logo = @'
|
||||||
|
@ -84,16 +97,24 @@ function Get-PoshThemes {
|
||||||
|___/
|
|___/
|
||||||
'@
|
'@
|
||||||
Write-Host $logo
|
Write-Host $logo
|
||||||
$poshCommand = Get-PoshCommand
|
$themes = Get-ChildItem -Path "$PSScriptRoot\themes\*" -Include '*.omp.json' | Sort-Object Name
|
||||||
Get-ChildItem -Path "$PSScriptRoot\themes\*" -Include '*.omp.json' | Sort-Object Name | ForEach-Object -Process {
|
|
||||||
Write-Host ("-" * $consoleWidth)
|
Write-Host ("-" * $consoleWidth)
|
||||||
|
if ($list -eq $true) {
|
||||||
|
$themes | Select-Object fullname | Format-Table -HideTableHeaders
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$poshCommand = Get-PoshCommand
|
||||||
|
$themes | ForEach-Object -Process {
|
||||||
Write-Host "Theme: $esc[1m$($_.BaseName.Replace('.omp', ''))$esc[0m"
|
Write-Host "Theme: $esc[1m$($_.BaseName.Replace('.omp', ''))$esc[0m"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
& $poshCommand -config $($_.FullName) -pwd $PWD
|
& $poshCommand -config $($_.FullName) -pwd $PWD
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Write-Host ("-" * $consoleWidth)
|
Write-Host ("-" * $consoleWidth)
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
Write-Host "Themes location: $PSScriptRoot\themes"
|
||||||
|
Write-Host ""
|
||||||
Write-Host "To change your theme, use the Set-PoshPrompt command. Example:"
|
Write-Host "To change your theme, use the Set-PoshPrompt command. Example:"
|
||||||
Write-Host " Set-PoshPrompt -Theme jandedobbeleer"
|
Write-Host " Set-PoshPrompt -Theme jandedobbeleer"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
Loading…
Reference in a new issue