Repository navigation
Expand file tree
/
Copy pathMicrosoft.PowerShell_profile.ps1
More file actions
52 lines (47 loc) · 1.84 KB
/
Copy pathMicrosoft.PowerShell_profile.ps1
File metadata and controls
52 lines (47 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$ProfileModuleRoot = Join-Path $PSScriptRoot "Profile"
$Global:ProfileDirectory = $ProfileModuleRoot
$ProfileParts = @(
"Settings.ps1"
"Common.ps1"
"Git.ps1"
"Prompt.ps1"
"Utilities.ps1"
"Shortcuts.ps1"
"SystemInfo.ps1"
"Pip.ps1"
"Aliases.ps1"
"LazyLoaders.ps1"
)
$Global:ProfileLoadTimings = [Collections.Generic.List[object]]::new()
foreach ($ProfilePart in $ProfileParts) {
$ProfilePartPath = Join-Path $ProfileModuleRoot $ProfilePart
if (-not (Test-Path -LiteralPath $ProfilePartPath)) {
Write-Warning "Profile part not found: $ProfilePartPath"
continue
}
$ProfilePartTimer = [Diagnostics.Stopwatch]::StartNew()
try {
. ([scriptblock]::Create([IO.File]::ReadAllText($ProfilePartPath)))
}
catch {
Write-Warning "Failed to load profile part '$ProfilePart': $($_.Exception.Message)"
}
$Global:ProfileLoadTimings.Add([PSCustomObject]@{ Part = $ProfilePart; Milliseconds = $ProfilePartTimer.Elapsed.TotalMilliseconds })
}
if ($Global:UserSettings["Microsoft.PowerShell.Profile:EnableMathModule"] -ne $false) {
$MathModulePath = Join-Path $ProfileModuleRoot "Math.psm1"
$ProfilePartTimer = [Diagnostics.Stopwatch]::StartNew()
if (Test-Path -LiteralPath $MathModulePath) {
try {
Import-Module $MathModulePath -Global -DisableNameChecking -ErrorAction Stop
}
catch {
Write-Warning "Failed to load Math module: $($_.Exception.Message)"
}
$Global:ProfileLoadTimings.Add([PSCustomObject]@{ Part = "Math.psm1"; Milliseconds = $ProfilePartTimer.Elapsed.TotalMilliseconds })
}
else {
Write-Warning "Profile part not found: $MathModulePath"
}
}
Remove-Variable ProfileModuleRoot, ProfileParts, ProfilePart, ProfilePartPath, ProfilePartTimer, MathModulePath -ErrorAction SilentlyContinue