From b20ef19dfb5a70d582c21207a60d97ff378778f9 Mon Sep 17 00:00:00 2001 From: Edward Delaporte Date: Thu, 22 Dec 2022 11:13:36 -0600 Subject: [PATCH] Use `files` path to PowerShell profile --- install/favorite-ps-modules.ps1 | 2 +- {install => setup}/profile.ps1 | 74 +++++++++++++-------------------- 2 files changed, 31 insertions(+), 45 deletions(-) rename {install => setup}/profile.ps1 (55%) diff --git a/install/favorite-ps-modules.ps1 b/install/favorite-ps-modules.ps1 index 214fc33..e8d72cc 100644 --- a/install/favorite-ps-modules.ps1 +++ b/install/favorite-ps-modules.ps1 @@ -3,4 +3,4 @@ Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted # Install nice Git stuff. -Install-Module -Name posh-git \ No newline at end of file +PowerShellGet\Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force \ No newline at end of file diff --git a/install/profile.ps1 b/setup/profile.ps1 similarity index 55% rename from install/profile.ps1 rename to setup/profile.ps1 index e1061ac..88bb380 100644 --- a/install/profile.ps1 +++ b/setup/profile.ps1 @@ -1,44 +1,30 @@ -<# -.SYNOPSIS - -Setup EdTheDev's PowerShell Profile - -.NOTES - -#> - -# Setup my PowerShell Profile (on Windows) -if(-Not(Test-Path -Path $profile)) { - New-Item -Path "$profile" -ItemType File -} - -# Install Stub PowerShell Profile that sources the one from DotFiles -$sourceMeFile = "$pwd\Microsoft.PowerShell_profile.ps1" -$sourceMeLine = '$profileContents = [string]::join([environment]::newline, (get-content -path ' -$sourceMeLine += $sourceMeFile -$sourceMeLine += '));invoke-expression $profileContents' - -# $doneFlagFile = "./DONE.md" -# $doBootStrap = -Not (Test-Path -Path $doneFlagFile) - -$profileStuff = Get-Content -Path $profile -if($profileStuff -Contains $sourceMeLine) { - Write-Host "Found profile source line: $sourceMeLine" - Write-Host "in file $profile" -} -else { - Write-Host "Profile source line will be added to $profile" - Add-Content -Path $profile -Value "" # Blank line to enforce newline. - Add-Content -Path $profile -Value $sourceMeLine -} - -# Install profile for Windows Terminal -# $destFile = "C:\Users\delaport\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\profiles.json" -# if(-Not(Test-Path -Path $destFile)) { -# Copy-Item -Path ./profiles.json -Destination $destFile -# } else { -# # Brute force ensure we update our git copy once in awhile. -# Copy-Item -Path $destFile -Destination ./profiles.json -#} - -PowerShellGet\Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force \ No newline at end of file +<# +.SYNOPSIS + +Setup EdTheDev's PowerShell Profile + +.NOTES + +#> + +# Setup my PowerShell Profile (on Windows) +if(-Not(Test-Path -Path $profile)) { + New-Item -Path "$profile" -ItemType File +} + +# Install Stub PowerShell Profile that sources the one from DotFiles +$sourceMeFile = "$pwd\files\Microsoft.PowerShell_profile.ps1" +$sourceMeLine = '$profileContents = [string]::join([environment]::newline, (get-content -path ' +$sourceMeLine += $sourceMeFile +$sourceMeLine += '));invoke-expression $profileContents' + +$profileStuff = Get-Content -Path $profile +if($profileStuff -Contains $sourceMeLine) { + Write-Host "Found profile source line: $sourceMeLine" + Write-Host "in file $profile" +} +else { + Write-Host "Profile source line will be added to $profile" + Add-Content -Path $profile -Value "" # Blank line to enforce newline. + Add-Content -Path $profile -Value $sourceMeLine +} -- 2.47.3