Last active
March 18, 2025 14:53
-
-
Save dprice/8088a9c1fa23884aa0bc29634caf2ed5 to your computer and use it in GitHub Desktop.
PowerShell Profile #tag PowerShell
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
$sw = [Diagnostics.Stopwatch]::StartNew() | |
Write-Host "Updating path..." -foregroundColor DarkGreen | |
if(!($env:path).contains((Split-Path $PROFILE))) { | |
$env:path += ";" + (Split-Path $PROFILE) | |
} | |
if(!($env:path).contains('D:\dNx\dnx-util;')) { | |
$env:path += ";" + 'D:\dNx\dnx-util;' | |
} | |
if(!($env:path).contains('D:\dNx\dnx-util\test;')) { | |
$env:path += ";" + 'D:\dNx\dnx-util\test;' | |
} | |
Write-Host "Elapsed time: $($sw.Elapsed)`n" -foregroundColor DarkGreen | |
Write-Host "Creating aliases and functions..." -foregroundColor DarkGreen | |
Set-Alias vs15 "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe" | |
Set-Alias vs17 "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe" | |
Set-Alias stree "${env:ProgramFiles(x86)}\Atlassian\SourceTree\SourceTree.exe" | |
function Get-ChuckNorrisFact{Invoke-Expression("Get-Content C:\dNx\dnx-util\ChuckNorrisFactsFiltered.txt | Get-Random | clip.exe")} | |
# function dberrors{Invoke-Expression("& '${env:ProgramFiles(x86)}\LINQPad4\lprun.exe' 'C:\Users\derek.price\Documents\LINQPad Queries\dNx\Rick Dodd Logging Queries Linq Version.linq' | Out-GridView")} | |
# function dbconns{Invoke-Expression("& '${env:ProgramFiles(x86)}\LINQPad4\lprun.exe' 'C:\Users\derek.price\Documents\LINQPad Queries\Misc\Database Connections Count.linq' | Out-GridView")} | |
Write-Host "Elapsed time: $($sw.Elapsed)`n" -foregroundColor DarkGreen | |
Write-Host "Loading history..." -foregroundColor DarkGreen | |
$MaximumHistoryCount = 31KB | |
$ImportedHistoryCount = 0 | |
$HistoryDirPath = "D:\Users\derek.price\Dropbox\UL\PowerShell\History\" | |
$HistoryFileName = "history.clixml" | |
if (!(Test-Path $HistoryDirPath -PathType Container)) { | |
New-Item $HistoryDirPath -ItemType Directory | |
} | |
Register-EngineEvent PowerShell.Exiting -Action { | |
$TotalHistoryCount = 0 | |
Get-History | Where-Object { $TotalHistoryCount++; $true } | |
$RecentHistoryCount = $TotalHistoryCount - $ImportedHistoryCount | |
$RecentHistory = Get-History -Count $RecentHistoryCount | |
if (!(Test-path ($HistoryDirPath + $HistoryFileName))) { | |
Get-History | Export-Clixml ($HistoryDirPath + $HistoryFileName) | |
} else { | |
$OldHistory = Import-Clixml ($HistoryDirPath + $HistoryFileName) | |
$NewHistory = @($OldHistory + $RecentHistory) | |
$NewHistory | Export-Clixml ($HistoryDirPath + $HistoryFileName) | |
} | |
} | |
if (Test-path ($HistoryDirPath + $HistoryFileName)) { | |
Import-Clixml ($HistoryDirPath + $HistoryFileName) | Where-Object { $count++;$true } | Add-History | |
Write-Output "`nLoaded $count history item(s).`n" | |
$ImportedHistoryCount = $count | |
} | |
Write-Host "Elapsed time: $($sw.Elapsed)`n" -foregroundColor DarkGreen | |
Write-Host "Importing modules..." -foregroundColor DarkGreen | |
# Import-Module "${env:ProgramFiles}\WindowsPowerShell\Modules\Invoke-MsBuild\2.2.0\Invoke-MsBuild.psm1" | |
Import-Module Invoke-MsBuild | |
Set-Alias msb Invoke-MsBuild | |
#Set-Location "$HOME\Documents\WindowsPowerShell" | |
Import-Module 'C:\Users\derek.price\Documents\WindowsPowerShell\Modules\Jump.Location\Jump.Location.psd1' | |
Import-Module posh-git | |
# Importing PSReadline must come AFTER you load your command history | |
if ($host.Name -eq 'ConsoleHost') { | |
Import-Module -Name PSReadline | |
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward | |
} | |
Set-PSReadlineKeyHandler -Key Ctrl+Shift+P ` | |
-BriefDescription CopyPathToClipboard ` | |
-LongDescription "Copies the current path to the clipboard" ` | |
-ScriptBlock { $pwd.Path.Trim() | clip } | |
Write-Host "Elapsed time: $($sw.Elapsed)`n" -foregroundColor DarkGreen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment