From 0718bf28c711f8f7f6e87f06060a3970e4c7d459 Mon Sep 17 00:00:00 2001 From: lksz Date: Thu, 1 Oct 2020 00:28:57 -0400 Subject: [PATCH 1/2] Minor midifications --- Reload-MyScripts.ps1 | 2 +- Setup-Profile.ps1 | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Reload-MyScripts.ps1 b/Reload-MyScripts.ps1 index fd0aca3..a9eac00 100644 --- a/Reload-MyScripts.ps1 +++ b/Reload-MyScripts.ps1 @@ -1,7 +1,7 @@ [CmdletBinding(SupportsShouldProcess)]param() $local:myAliases = [ordered]@{} -$myAliases.sudo = 'Invoke-Sudo' +#$myAliases.sudo = 'Invoke-Sudo' $myAliases.vi = 'Edit-TextFile' $myAliases.vim = 'Edit-TextFile' $myAliases.nvim = 'Edit-TextFile' diff --git a/Setup-Profile.ps1 b/Setup-Profile.ps1 index 0173767..b5a3cfb 100644 --- a/Setup-Profile.ps1 +++ b/Setup-Profile.ps1 @@ -414,6 +414,8 @@ if ( -not $MyPSScriptRoot -or (Test-Path function:Test-IsAdmin, function:Convert . ProfileCode_common } +$SetupFromWeb = [bool]$(@( $SetupFromWeb, $sfw, $LoadCode ) | Where-Object { $_ }) + if ( -not $SetupFromWeb ) { _setup @PSBoundParameters Get-Item function:_setup | Remove-Item From a782d09b2c728e393856e650dc7034f4206ca157 Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Thu, 1 Oct 2020 18:16:54 -0400 Subject: [PATCH 2/2] fixed scoping issue --- Setup-Profile.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Setup-Profile.ps1 b/Setup-Profile.ps1 index b5a3cfb..fcfb59f 100644 --- a/Setup-Profile.ps1 +++ b/Setup-Profile.ps1 @@ -380,10 +380,10 @@ param([string]$EnvPath) # Establish Module Path $global:MyPSModulePath = Split-PathEnv $env:PSModulePath | -Where-Object { $_ -match "^$($(Resolve-Path ~) -replace '\\',"\\")" } | -Where-Object { Test-Path $_ } | -Get-Item | Sort-Object -Property LastWriteTime -Descending | -Select-Object -ExpandProperty FullName -First 1 + Where-Object { $_ -match "^$($(Resolve-Path ~) -replace '\\',"\\")" } | + Where-Object { Test-Path $_ } | + Get-Item | Sort-Object -Property LastWriteTime -Descending | + Select-Object -ExpandProperty FullName -First 1 if ( -not $MyPSModulePath ) { $MyPSModulePath = $(Join-Path $(Join-Path $(Resolve-Path ~) 'powershell') 'Modules') @@ -409,10 +409,12 @@ $p = @($p[0], $MyPSScriptRoot) + $($p | Select-Object -Skip 1) $env:PATH = $p -join $PathEnvDelimiter } +$local:importExpression = "" if ( -not $MyPSScriptRoot -or (Test-Path function:Test-IsAdmin, function:ConvertTo-Base64, function:Invoke-ExpressionEx, function:Get-PowerShellPath, function:Export-FunctionSource | Where-Object { -not $_ } | Measure-Object | Select-Object -ExpandProperty Count) ) { Write-Verbose "Calling ProfileCode inline..." - . ProfileCode_common + $importExpression = "ProfileCode_common" } +. Invoke-Expression $importExpression $SetupFromWeb = [bool]$(@( $SetupFromWeb, $sfw, $LoadCode ) | Where-Object { $_ })