Last active
September 17, 2018 17:56
-
-
Save whoisj/eff6539d489da9dcb36a721c6556366e to your computer and use it in GitHub Desktop.
PowerShell profile init
This file contains 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
Set-StrictMode -Version Latest | |
$powershellModulesPath = 'E:\Users\jwyman\Documents\WindowsPowerShell\Modules' | |
if ([System.String]::IsNullOrEmpty("$env:MSYSTEM")) { | |
$sw = [Diagnostics.Stopwatch]::StartNew(); | |
$global = "$env:APPDATA\Profile.ps1" | |
$local = "$env:LOCALAPPDATA\Profile.ps1" | |
if (-not (test-path "$global")) | |
{ | |
(new-item -path "$global" -itemtype 'file') 2>&1 | out-null | |
} | |
if (-not (test-path "$local")) | |
{ | |
(new-item -path "$local" -itemtype 'file') 2>&1 | out-null | |
} | |
. $global | |
. $local | |
$sw.Stop() | |
$profileElapsed = $sw.ElapsedMilliseconds | |
$sw.Restart() | |
Push-Location "$powershellModulesPath" | |
# Load posh-git module from current directory | |
Import-Module .\posh-git | |
$WindowTitleSupported = $false | |
# Set up a simple prompt, adding the git prompt parts inside git repos | |
function global:prompt { | |
$realLASTEXITCODE = $LASTEXITCODE | |
Write-VcsStatus | |
$global:LASTEXITCODE = $realLASTEXITCODE | |
return "> " | |
} | |
Pop-Location | |
$sw.Stop() | |
$poshElapsed = $sw.ElapsedMilliseconds | |
$sw.Restart() | |
# Start-SshAgent -Quiet | |
$sw.Stop() | |
$sshagentElapsed = $sw.ElapsedMilliseconds | |
Write-Host "Profiles: $($profileElapsed)ms | Posh: $($poshElapsed)ms | SshAgent: $($sshagentElapsed)ms" | |
} | |
set-psdebug -off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment