Forked from phil-scott-78/Microsoft.PowerShell_profile.ps1
Created
December 8, 2021 14:29
-
-
Save johnsonlu/e5141d45b1ead51affa4ad02e6c5681f to your computer and use it in GitHub Desktop.
Powershell Profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Set-Progress { | |
| param( [int]$Percent ) | |
| if ($Progress -lt 100) { | |
| Write-Host -NoNewline "`e]9;4;1;${Percent}`e\" | |
| } | |
| else { | |
| Write-Host -NoNewline "`e]9;4;0`e\" | |
| } | |
| } | |
| [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding | |
| $StrippedUnicode = 'u+2705' -replace 'U\+','' | |
| $UnicodeInt = [System.Convert]::toInt32($StrippedUnicode,16) | |
| $CheckChar = [System.Char]::ConvertFromUtf32($UnicodeInt) | |
| $stopwatch = [system.diagnostics.stopwatch]::StartNew() | |
| #hides the cursor | |
| Write-Host "`e[?25l" -NoNewline | |
| Write-Host "Loading PowerShell $($PSVersionTable.PSVersion)..." -ForegroundColor 3 | |
| Write-Host | |
| # this takes a sec, but we can also do it concurrently with the rest of the profile loading | |
| $vsshell = Start-ThreadJob { | |
| Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" | |
| Enter-VsDevShell d0d15d66 -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64" | Out-Null | |
| } | |
| # posh-git | |
| Set-Progress 10 | |
| Write-Host -NoNewline "Loading poshgit`t`t" | |
| Import-Module posh-git | |
| $env:POSH_GIT_ENABLED = $true | |
| Write-Host $CheckChar | |
| # oh-my-posh | |
| Set-Progress 25 | |
| Write-Host -NoNewline "Loading oh-my-posh`t" | |
| Import-Module oh-my-posh | |
| Write-Host $CheckChar | |
| set-poshprompt C:\Users\phils\hotstick.omp.json | |
| $DefaultUser = 'phils' | |
| Set-Progress 65 | |
| # Chocolatey profile | |
| Write-Host -NoNewline "Loading Chocolatey`t" | |
| $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
| if (Test-Path($ChocolateyProfile)) { | |
| Import-Module "$ChocolateyProfile" | |
| Write-Host $CheckChar | |
| } | |
| Set-Progress 75 | |
| Write-Host -NoNewline "Loading ZLocation`t" | |
| Import-Module ZLocation | |
| Write-Host $CheckChar | |
| Set-Progress 90 | |
| Write-Host -NoNewline "Loading VS2022 Shell`t" | |
| # we already started this task earlier, just gotta receive it now | |
| Receive-Job $vsshell | |
| Write-Host $CheckChar | |
| # show the cursor and complete the progress | |
| Write-Host "`e[?25h" -NoNewline | |
| Set-Progress 100 | |
| Write-Host "`nProfile loaded in " $stopwatch.Elapsed.TotalMilliseconds "ms" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment