diff --git a/Setup-ScriptEnv.ps1 b/Setup-ScriptEnv.ps1 index 8b9ef92..acf0b28 100644 --- a/Setup-ScriptEnv.ps1 +++ b/Setup-ScriptEnv.ps1 @@ -386,7 +386,9 @@ function _Init { [switch]$NoReloadScripts ) - . LoadProfileCodeFunctions + $local:LoadMissing = ". LoadProfileCodeFunctions" + if( Test-Path function:ProfileCode_cleanup ) { $LoadMissing = "#" } + . Invoke-Expression $LoadMissing if ( -not $NoGitAction ) { if ( -not [bool]$(Get-Command git -ErrorAction SilentlyContinue) ) { @@ -437,22 +439,20 @@ function _Init { if( $_profile ) { $_profiles += ,$_profile } else { - $_profiles = $PROFILE | fl * -Force | Out-String -Stream | ForEach-Object { - $local:p = $($_ -split ' : [/A-Z\\]'); - if ( $p[0] -match 'User' ) { - $p[0].Trim() - } - } + $_profiles = $PROFILE | Get-Member -Type NoteProperty | + Select-Object -ExpandProperty Name $_profile = $profile.CurrentUserAllHosts; if ( $sudo -or $(Test-IsAdmin) ) { $_profile = $profile.AllUsersAllHosts } } + Write-Verbose $( $_profiles | Out-String ) + Write-Verbose $( $_profile | Out-String ) if ( $RemoveOnly -and $ConfirmPreference -eq 'High' -and (-not $PSBoundParameters -or -not $PSBoundParameters.ContainsKey('Confirm')) ) { $script:ConfirmPreference = 'Low' } $_profiles | Foreach-Object { - $local:p = $profile."$_" + $local:p = Invoke-Expression "`$profile.$_" if( -not $p ) { $p = $_ } $local:profileContent = $randomSeed; $local:exists = Test-Path $p @@ -579,7 +579,9 @@ if( $WriteInitScript ) { _Init @PSBoundParameters } -. ProfileCode_cleanup +if( Test-Path function:ProfileCode_cleanup ) { + . ProfileCode_cleanup +} if( $NoReloadScripts ) { return } diff --git a/base/Get-Profiles.ps1 b/base/Get-Profiles.ps1 index 0cd1acb..73748a4 100644 --- a/base/Get-Profiles.ps1 +++ b/base/Get-Profiles.ps1 @@ -2,12 +2,14 @@ [switch]$AsDictionary ) -filter ConvertTo-Hash { param([string]$Property="Name") begin { $hash = @{} } process{ $hash[$_."$Property"] = $_ } end {return $hash} } +filter ConvertTo-Hash { param([string]$Property='Name') begin { $hash = @{} } process{ $hash[$_."$Property"] = $_ } end {return $hash} } -$local:rVal = $PROFILE | fl * -Force | Out-String -Stream | Where-Object { $_ -match '( : /)|(:\\)' } | - Select-Object @{ - N="Profile";E={($_ -split ": ")[0].Trim()} - },@{N="Path";E={($_ -split ": ")[-1].Trim()} -} | Select-Object *,@{N="Exists";E={Test-Path $_.Path}} +$local:rVal = $PROFILE | Get-Member -Type NoteProperty | + Select-Object -ExpandProperty Name | + Select-Object @{ + N='Profile';E={$_} + },@{N='Path';E={$PROFILE."$_"} + } | + Select-Object *,@{N="Exists";E={Test-Path $_.Path}} if( $AsDictionary ) { return $rVal | ConvertTo-Hash -Property "Profile" } return $rVal diff --git a/base/src/config.files.json b/base/src/config.files.json index 3c9fa10..2d2e831 100644 --- a/base/src/config.files.json +++ b/base/src/config.files.json @@ -10,6 +10,11 @@ "/zsys": "/etc/zsys.conf", "shrc": "~/.shrc", "sz-aliases-sh": "~/.sz.aliases.sh", + "szload": [ + "@shell-loading-snippets/zsh", + "@shell-loading-snippets/bash", + "@shell-loading-snippets/sh" + ], "sz-shrc": [ "~/.sz.shrc.sh", "#shrc",