File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ # -----------------------------------------------------------------------------
2
+ # PowerShell Profile - Prompt
3
+ # -----------------------------------------------------------------------------
4
+
5
+ Class OMPThemes : System.Management.Automation.IValidateSetValuesGenerator {
6
+ [String []] GetValidValues() {
7
+ $OMPThemes = ((Get-ChildItem - Path " $Env: POSH_THEMES_PATH " - Filter " *.omp.json" ).Name -replace " .omp.json" , " " )
8
+ return [String []]$OMPThemes
9
+ }
10
+ }
11
+
12
+ Function Set-OMPTheme {
13
+ [CmdletBinding ()]
14
+ Param (
15
+ [ValidateSet ([OMPThemes ])]
16
+ [String ]$Theme
17
+ )
18
+
19
+ try {
20
+ $ConfigPath = Join-Path " $Env: POSH_THEMES_PATH " " $Theme .omp.json"
21
+ (& oh- my- posh init pwsh -- config= $ConfigPath -- print) -join " `n " | Invoke-Expression
22
+ } catch [CommandNotFoundException ] {
23
+ Write-Warning " Failed to set oh-my-posh theme"
24
+ return
25
+ } finally {
26
+ if ($? ) {
27
+ Write-Verbose " oh-my-posh theme set to '$Theme '"
28
+ $Global :POSH_THEME = $Theme
29
+ }
30
+ }
31
+
32
+ }
33
+
34
+ if (Get-Command oh- my- posh - ErrorAction SilentlyContinue) {
35
+ Write-Verbose " Setting oh-my-posh theme..."
36
+ Set-OMPTheme - Theme space
37
+ }
You can’t perform that action at this time.
0 commit comments