=Fix profile listing mechanism
This commit is contained in:
parent
685077b250
commit
cdabbc7858
|
@ -386,7 +386,9 @@ function _Init {
|
||||||
[switch]$NoReloadScripts
|
[switch]$NoReloadScripts
|
||||||
)
|
)
|
||||||
|
|
||||||
. LoadProfileCodeFunctions
|
$local:LoadMissing = ". LoadProfileCodeFunctions"
|
||||||
|
if( Test-Path function:ProfileCode_cleanup ) { $LoadMissing = "#" }
|
||||||
|
. Invoke-Expression $LoadMissing
|
||||||
|
|
||||||
if ( -not $NoGitAction ) {
|
if ( -not $NoGitAction ) {
|
||||||
if ( -not [bool]$(Get-Command git -ErrorAction SilentlyContinue) ) {
|
if ( -not [bool]$(Get-Command git -ErrorAction SilentlyContinue) ) {
|
||||||
|
@ -437,22 +439,20 @@ function _Init {
|
||||||
if( $_profile ) {
|
if( $_profile ) {
|
||||||
$_profiles += ,$_profile
|
$_profiles += ,$_profile
|
||||||
} else {
|
} else {
|
||||||
$_profiles = $PROFILE | fl * -Force | Out-String -Stream | ForEach-Object {
|
$_profiles = $PROFILE | Get-Member -Type NoteProperty |
|
||||||
$local:p = $($_ -split ' : [/A-Z\\]');
|
Select-Object -ExpandProperty Name
|
||||||
if ( $p[0] -match 'User' ) {
|
|
||||||
$p[0].Trim()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_profile = $profile.CurrentUserAllHosts;
|
$_profile = $profile.CurrentUserAllHosts;
|
||||||
if ( $sudo -or $(Test-IsAdmin) ) { $_profile = $profile.AllUsersAllHosts }
|
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')) ) {
|
if ( $RemoveOnly -and $ConfirmPreference -eq 'High' -and (-not $PSBoundParameters -or -not $PSBoundParameters.ContainsKey('Confirm')) ) {
|
||||||
$script:ConfirmPreference = 'Low'
|
$script:ConfirmPreference = 'Low'
|
||||||
}
|
}
|
||||||
|
|
||||||
$_profiles | Foreach-Object {
|
$_profiles | Foreach-Object {
|
||||||
$local:p = $profile."$_"
|
$local:p = Invoke-Expression "`$profile.$_"
|
||||||
if( -not $p ) { $p = $_ }
|
if( -not $p ) { $p = $_ }
|
||||||
$local:profileContent = $randomSeed;
|
$local:profileContent = $randomSeed;
|
||||||
$local:exists = Test-Path $p
|
$local:exists = Test-Path $p
|
||||||
|
@ -579,7 +579,9 @@ if( $WriteInitScript ) {
|
||||||
_Init @PSBoundParameters
|
_Init @PSBoundParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
. ProfileCode_cleanup
|
if( Test-Path function:ProfileCode_cleanup ) {
|
||||||
|
. ProfileCode_cleanup
|
||||||
|
}
|
||||||
|
|
||||||
if( $NoReloadScripts ) { return }
|
if( $NoReloadScripts ) { return }
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
[switch]$AsDictionary
|
[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 '( : /)|(:\\)' } |
|
$local:rVal = $PROFILE | Get-Member -Type NoteProperty |
|
||||||
Select-Object @{
|
Select-Object -ExpandProperty Name |
|
||||||
N="Profile";E={($_ -split ": ")[0].Trim()}
|
Select-Object @{
|
||||||
},@{N="Path";E={($_ -split ": ")[-1].Trim()}
|
N='Profile';E={$_}
|
||||||
} | Select-Object *,@{N="Exists";E={Test-Path $_.Path}}
|
},@{N='Path';E={$PROFILE."$_"}
|
||||||
|
} |
|
||||||
|
Select-Object *,@{N="Exists";E={Test-Path $_.Path}}
|
||||||
if( $AsDictionary ) { return $rVal | ConvertTo-Hash -Property "Profile" }
|
if( $AsDictionary ) { return $rVal | ConvertTo-Hash -Property "Profile" }
|
||||||
return $rVal
|
return $rVal
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
"/zsys": "/etc/zsys.conf",
|
"/zsys": "/etc/zsys.conf",
|
||||||
"shrc": "~/.shrc",
|
"shrc": "~/.shrc",
|
||||||
"sz-aliases-sh": "~/.sz.aliases.sh",
|
"sz-aliases-sh": "~/.sz.aliases.sh",
|
||||||
|
"szload": [
|
||||||
|
"@shell-loading-snippets/zsh",
|
||||||
|
"@shell-loading-snippets/bash",
|
||||||
|
"@shell-loading-snippets/sh"
|
||||||
|
],
|
||||||
"sz-shrc": [
|
"sz-shrc": [
|
||||||
"~/.sz.shrc.sh",
|
"~/.sz.shrc.sh",
|
||||||
"#shrc",
|
"#shrc",
|
||||||
|
|
Loading…
Reference in New Issue