Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
Fallback to home folder for themes location
Browse files Browse the repository at this point in the history
There are machines without the $PROFILE variable. In that case this
code fails as it can't find the location and will crash. Now we Fallback
to the home folder to look for any additional user created themes.

Resolves #168.
  • Loading branch information
JanDeDobbeleer committed Nov 10, 2019
1 parent ac27f09 commit 4f4117e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion defaults.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Oh-My-Posh default settings
function Get-ThemesLocation {
$folderName = "PoshThemes"
if ($PROFILE) {
return (Join-Path (Split-Path -Parent $PROFILE) $folderName)
}
return "~\${$folderName}"
}

$global:ThemeSettings = New-Object -TypeName PSObject -Property @{
CurrentUser = [System.Environment]::UserName
CurrentThemeLocation = "$PSScriptRoot\Themes\Agnoster.psm1"
MyThemesLocation = (Join-Path (Split-Path -Parent $PROFILE) "PoshThemes")
MyThemesLocation = Get-ThemesLocation
ErrorCount = 0
GitSymbols = @{
BranchSymbol = [char]::ConvertFromUtf32(0xE0A0)
Expand Down
3 changes: 2 additions & 1 deletion oh-my-posh.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ FunctionsToExport = @('Show-Colors',
'Test-NotDefaultUser',
'Test-Administrator',
'Get-ComputerName',
'Set-Newline')
'Set-Newline',
'Get-ThemesLocation')

# Private data to pass to the module specified in RootModule. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
Expand Down

0 comments on commit 4f4117e

Please sign in to comment.