Files
dotfiles/Documents/PowerShell/Microsoft.PowerShell_profile.ps1
T

34 lines
1.1 KiB
PowerShell
Raw Normal View History

2026-07-17 22:23:00 -05:00
$CurrentDir = if ($PSScriptRoot) { $PSScriptRoot } else { Split-Path -Parent $PROFILE }
$ProfileDir = Join-Path -Path $CurrentDir -ChildPath "Profile"
2026-07-07 18:28:35 -05:00
2026-07-17 22:23:00 -05:00
if (Test-Path -Path $ProfileDir) {
$mutexName = "Global\PowerShellProfileInit"
$mutex = [System.Threading.Mutex]::new($false, $mutexName)
$acquired = $false
try {
$acquired = $mutex.WaitOne(10000)
if ($acquired) {
$ProfileScripts = Get-ChildItem -Path $ProfileDir -Filter "*.ps1" | Sort-Object Name
foreach ($Script in $ProfileScripts) {
try {
. $Script.FullName
}
catch {
Write-Warning "Failed to load profile module: $($Script.Name). Error: $($_.Exception.Message)"
}
}
2026-07-07 18:28:35 -05:00
}
else {
Write-Warning "Profile initialization lock timed out — another terminal may be loading."
2026-07-07 18:28:35 -05:00
}
}
finally {
if ($acquired) { $mutex.ReleaseMutex() }
$mutex.Dispose()
}
}
else {
2026-07-17 22:23:00 -05:00
Write-Warning "Profile directory not found at: $ProfileDir"
2026-07-07 18:28:35 -05:00
}