diff options
Diffstat (limited to '.config/powershell/bootstrap.ps1')
| -rw-r--r-- | .config/powershell/bootstrap.ps1 | 107 |
1 files changed, 54 insertions, 53 deletions
diff --git a/.config/powershell/bootstrap.ps1 b/.config/powershell/bootstrap.ps1 index 98c291d..6515808 100644 --- a/.config/powershell/bootstrap.ps1 +++ b/.config/powershell/bootstrap.ps1 @@ -1,7 +1,8 @@ # Requires -RunAsAdministrator # Set execution policy to remote signed -Set-ExecutionPolicy RemoteSigned +#Set-ExecutionPolicy RemoteSigned +Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force # Set network category to private Set-NetConnectionProfile -NetworkCategory Private @@ -11,9 +12,9 @@ $dotfiles_url = 'https://github.com/srdusr/dotfiles.git' $dotfiles_dir = "$HOME\.cfg" # Imports -. .\initialize.ps1 -. .\ownership.ps1 -. .\onedrive.ps1 +. $HOME\.config\powershell\initialize.ps1 +. $HOME\.config\powershell\ownership.ps1 +. $HOME\.config\powershell\onedrive.ps1 # Function to handle errors function handle_error { @@ -93,6 +94,46 @@ foreach ($app in $apps) { force-mkdir "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Cloud Content" Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Cloud Content" "DisableWindowsConsumerFeatures" 1 +# Configure PowerShell +Write-Host "Configuring PowerShell" +Write-Host "----------------------------------------" + +# Get the "MyDocuments" path for the current user, excluding OneDrive +$UserMyDocumentsPath = [System.Environment]::GetFolderPath('MyDocuments').Replace("OneDrive", "") + "\Documents" + +$PowerShellProfileDirectory = "$UserMyDocumentsPath\PowerShell" +$PowerShellLegacySymlink = "$UserMyDocumentsPath\WindowsPowerShell" + +$PowerShellProfileTemplate = "$PSScriptRoot\$USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" +$env:PSModulePath = $env:PSModulePath -replace "\\OneDrive\\Documents\\WindowsPowerShell\\","\.powershell\" + +# Set documents path to user's local Documents folder +$documentsPath = "$UserMyDocumentsPath" +$powerShellProfileDir = "$documentsPath\PowerShell" + +# Output the chosen PowerShell profile directory +$PROFILE = "$powerShellProfileDir\Microsoft.PowerShell_profile.ps1" +Write-Host "PowerShell profile directory set to: $powerShellProfileDir" + +if (-not (Test-Path -Path $powerShellProfileDir)) { + New-Item -ItemType Directory -Path $powerShellProfileDir -Force +} + +New-Item -ItemType HardLink -Force ` + -Path "$powerShellProfileDir\Microsoft.PowerShell_profile.ps1" ` + -Target "$home\.config\powershell\Microsoft.PowerShell_profile.ps1" + +# Set environment variable +[System.Environment]::SetEnvironmentVariable('PowerShellProfileDir', $powerShellProfileDir, [System.EnvironmentVariableTarget]::User) + +Write-Host "PowerShell profile directory set to: $powerShellProfileDir" +Write-Host "Environment variable 'PowerShellProfileDir' set to: $powerShellProfileDir" + +# Verify profile sourcing +if (!(Test-Path -Path "$home\.config\powershell\Microsoft.PowerShell_profile.ps1")) { + handle_error "PowerShell profile does not exist. Please create it at $home\.config\powershell\Microsoft.PowerShell_profile.ps1" +} + # Install Chocolatey if not installed Write-Host "Installing Chocolatey" Write-Host "----------------------------------------" @@ -131,15 +172,15 @@ $apps = @( #"vscode", "nodejs", "bat", - "coreutils", - "delta", - "fnm", - "gh", - "less", - "lua", - "make", - "tokei", - "zoxide", + #"coreutils", + #"delta", + #"fnm", + #"gh", + #"less", + #"lua", + #"make", + #"tokei", + #"zoxide" ) foreach ($app in $apps) { @@ -158,46 +199,6 @@ foreach ($app in $apps) { } } -# Configure PowerShell -Write-Host "Configuring PowerShell" -Write-Host "----------------------------------------" - -# Get the "MyDocuments" path for the current user, excluding OneDrive -$UserMyDocumentsPath = [System.Environment]::GetFolderPath('MyDocuments').Replace("OneDrive", "") + "\Documents" - -$PowerShellProfileDirectory = "$UserMyDocumentsPath\PowerShell" -$PowerShellLegacySymlink = "$UserMyDocumentsPath\WindowsPowerShell" - -$PowerShellProfileTemplate = "$PSScriptRoot\$USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" -$env:PSModulePath = $env:PSModulePath -replace "\\OneDrive\\Documents\\WindowsPowerShell\\","\.powershell\" - -# Set documents path to user's local Documents folder -$documentsPath = "$UserMyDocumentsPath" -$powerShellProfileDir = "$documentsPath\PowerShell" - -# Output the chosen PowerShell profile directory -$PROFILE = "$powerShellProfileDir\Microsoft.PowerShell_profile.ps1" -Write-Host "PowerShell profile directory set to: $powerShellProfileDir" - -if (-not (Test-Path -Path $powerShellProfileDir)) { - New-Item -ItemType Directory -Path $powerShellProfileDir -Force -} - -New-Item -ItemType HardLink -Force ` - -Path "$powerShellProfileDir\Microsoft.PowerShell_profile.ps1" ` - -Target "$home\.config\powershell\Microsoft.PowerShell_profile.ps1" - -# Set environment variable -[System.Environment]::SetEnvironmentVariable('PowerShellProfileDir', $powerShellProfileDir, [System.EnvironmentVariableTarget]::User) - -Write-Host "PowerShell profile directory set to: $powerShellProfileDir" -Write-Host "Environment variable 'PowerShellProfileDir' set to: $powerShellProfileDir" - -# Verify profile sourcing -if (!(Test-Path -Path "$home\.config\powershell\Microsoft.PowerShell_profile.ps1")) { - handle_error "PowerShell profile does not exist. Please create it at $home\.config\powershell\Microsoft.PowerShell_profile.ps1" -} - # Define the `config` alias in the current session function global:config { git --git-dir="$env:USERPROFILE\.cfg" --work-tree="$env:USERPROFILE" $args |
