]> apps.delaporte.us Git - dotfiles.git/blob - Microsoft.PowerShell_profile.ps1
Merge branch 'master' of github.com:edthedev/dotfiles
[dotfiles.git] / Microsoft.PowerShell_profile.ps1
1 # .EXAMPLE
2 # . C:\src\dotfiles\Microsoft.PowerShell_profile.ps1
3
4 # Courtesty of MKletz
5 # Get-ChildItem -Path 'C:\Repos' -Filter "*.psd1" -Recurse | ForEach-Object -Process {
6 # $Path = Split-Path -Path $_.Directory -Parent
7 # $env:PSModulePath = $env:PSModulePath + ";$($Path)"
8 #}
9 # $env:PSModulePath = $env:PSModulePath.Replace("\\ad.uillinois.edu\techsvc\home\$($ENV:USERNAME)\Documents\PowerShell\Modules;",'')
10
11 # No longer needed in PowerShell 7
12 if(-Not $IsWindows) {
13 # Bootstrap for older PowerShell
14 Write-Host "***Bootstrapped Is Windows for older PowerShell***"
15 $IsWindows = ($env:OS -eq "Windows_NT")
16 }
17
18 $env:src = "~"
19 if($IsWindows){
20 Write-Host "***Is Windows***"
21 $env:src = "c:\src"
22 }
23
24 if($IsWindows){
25 # Some Paths that are annoying to find/restore if the installer fails
26 $ENV:PATH+=";C:\Program Files\Microsoft VS Code\bin" # One Editor to rule them all
27 $ENV:PATH+=";C:\Program Files\Git\cmd" # Version control is nice.
28 $ENV:PATH+=";C:\ProgramData\chocolatey\bin" # Package management is nice.
29 $ENV:PATH+=";C:\PENGUIN" # Flag to ensure my profile kicked in.
30 }
31
32
33 $env:Journal = "~\Journal\2021" # allows cd $env:journal
34 $env:minion = "$env:src\minion"
35
36 # Import some home grown PowerShell modules, if they are installed.
37 #
38 $modPaths = Get-Childitem -Path "$env:src\dotfiles\psmodules"
39 $modPaths += Get-Childitem -Path "$env:minion\psmodule"
40
41 # Windows Only Modules
42 if($IsWindows){
43 $modPaths += Get-Childitem -Path "$env:src\dotfiles\win_psmodules"
44 }
45 if($modPaths.length -eq 0){
46 Write-Host "No modules found."
47 }
48 $modPaths | ForEach-Object {
49 $fileName = $_.FullName
50 Import-Module $fileName
51 Write-Host ">> Loaded $fileName"
52 }
53
54
55
56 # Linux-like up/down in shell
57 Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
58 Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
59 Set-PSReadlineOption -HistorySavePath $env:src\PSHistory.log
60
61 # Minion alias commands - 'today'
62 # . C:\src\minion\profiles\alias.ps1
63 . $env:minion\profiles\alias.ps1
64 # Add Minion go executable to path.
65 . $env:minion\profiles\path.ps1
66 # Add Minion to path
67 Write-Host "+ Added minion command to path."
68 $ENV:PATH+=";$env:minion\go" # Flag to ensure my profile kicked in.
69
70 # Unix dies hard.
71 New-Alias which get-command
72
73 # Delay loading PoshGit for speed.
74 function Enable-PoshGit {
75 Import-Module posh-git
76 }
77 New-Alias pg Enable-PoshGit
78 Write-Host "+ Type 'pg' to enable PoshGit"
79
80
81 if((Get-Location).Path -eq $HOME){
82 cd $env:src
83 }