]> us-delaporte.pagekite.me Git - dotfiles.git/blob - setup/profile.ps1
Add helper to remove 'Search Highlights'
[dotfiles.git] / setup / profile.ps1
1 <#
2 .SYNOPSIS
3
4 Setup EdTheDev's PowerShell Profile
5
6 .NOTES
7
8 #>
9
10 # Setup my PowerShell Profile (on Windows)
11 if(-Not(Test-Path -Path $profile)) {
12 New-Item -Path "$profile" -ItemType File
13 }
14
15 # Install Stub PowerShell Profile that sources the one from DotFiles
16 $sourceMeFile = "$pwd\files\Microsoft.PowerShell_profile.ps1"
17 $sourceMeLine = '$profileContents = [string]::join([environment]::newline, (get-content -path '
18 $sourceMeLine += $sourceMeFile
19 $sourceMeLine += '));invoke-expression $profileContents'
20
21 $profileStuff = Get-Content -Path $profile
22 if($profileStuff -Contains $sourceMeLine) {
23 Write-Host "Found profile source line: $sourceMeLine"
24 Write-Host "in file $profile"
25 }
26 else {
27 Write-Host "Profile source line will be added to $profile"
28 Add-Content -Path $profile -Value "" # Blank line to enforce newline.
29 Add-Content -Path $profile -Value $sourceMeLine
30 }