Skip to content

Commit

Permalink
Speed up profile
Browse files Browse the repository at this point in the history
  • Loading branch information
codyduong committed Mar 18, 2024
1 parent 1bea999 commit 30af82d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions windows/.files/%USERPROFILE%/.wezterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local config = {
tab_bar_at_bottom = true,
use_fancy_tab_bar = false,
tab_max_width = 30,
adjust_window_size_when_changing_font_size = false,

-- use custom leaders
leader = { key="_", mods="SHIFT|CTRL|SUPER|ALT" },
Expand Down
8 changes: 6 additions & 2 deletions windows/components.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Get-ChildItem -Path "./components" | Where-Object { $_.extension -eq ".ps1" } |
}

# oh-my-posh
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\M365Princess.omp.json" | Invoke-Expression
# oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\M365Princess.omp.json" | Invoke-Expression
try {
Import-Module PSReadLine
}
Expand All @@ -15,9 +15,13 @@ Import-Module CompletionPredictor
$script:TerminalIconsForkPath = (Join-Path $env:USERPROFILE "Terminal-Icons")
if (Test-Path -Path $TerminalIconsForkPath -PathType Container) {
$script:TerminalIconsVersion = (Import-PowerShellDataFile (Join-Path $TerminalIconsForkPath "Terminal-Icons/Terminal-Icons.psd1")).ModuleVersion
Import-Module (Join-Path $TerminalIconsForkPath "Output/Terminal-Icons/$TerminalIconsVersion/Terminal-Icons.psd1")
$script:TerminalIconsModulePath = (Join-Path $TerminalIconsForkPath "Output/Terminal-Icons/$TerminalIconsVersion/Terminal-Icons.psd1")
# ~250ms here
# Write-Host $(Measure-Command {Import-Module $TerminalIconsModulePath)
Import-Module $TerminalIconsModulePath
}
else {
# ~500ms here
Import-Module Terminal-Icons
}

Expand Down
4 changes: 0 additions & 4 deletions windows/components/fuck.ps1

This file was deleted.

19 changes: 19 additions & 0 deletions windows/scripts/bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ for ($i = $bootstrapLines.Length; $i -ge 0; $i--) {
}
($bootstrapLines -join "`r`n") | Set-Content -Path $bootstrapAlias

## Setup thefuck alias
$script:fuckPath = Join-Path $aliasesDir "fuck.ps1"
thefuck --alias | Set-Content -Path $fuckPath

## Setup oh-my-posh (precompute here to save time)
# https://ohmyposh.dev/docs/configuration/debug-prompt <-- this prompt I never use, so manually disable it
# because we precompute the script file, the call-stack is not empty, thus thinking we are debugging, so just replace
# Saves around 70-100ms
$script:ohMyPoshPath = Join-Path $componentDir "ohmyposh.ps1"
(Invoke-Expression (@"

Check warning

Code scanning / PSScriptAnalyzer

Invoke-Expression is used. Please remove Invoke-Expression from script and find other options instead. Warning

Invoke-Expression is used. Please remove Invoke-Expression from script and find other options instead.
$(oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\M365Princess.omp.json")
"@ -replace "\|\s*Invoke-Expression",'')
) -replace '\$script:PromptType = \"debug\"',@"
#`$script:PromptType = `"debug`" # Disabled by bootstrap.ps1
`$script:PromptType = `"primary`"
"@
| Set-Content -Path $ohMyPoshPath


##############
# Config Files
##############
Expand Down

0 comments on commit 30af82d

Please sign in to comment.