]> us-delaporte.pagekite.me Git - dotfiles.git/blob - Microsoft.PowerShell_profile.ps1
Install PoshGit for PowerShell from PowerShell Gallery
[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($IsWindows -eq "") {
13 # # Bootstrap for older PowerShell
14 # $IsWindows = ($env:OS -eq "Windows_NT")
15 # }
16
17 #if($IsWindows){
18 # # Some Paths that are annoying to find/restore if the installer fails
19 # $ENV:PATH+=";C:\Program Files\Microsoft VS Code\bin" # One Editor to rule them all
20 # $ENV:PATH+=";C:\Program Files\Git\cmd" # Version control is nice.
21 # $ENV:PATH+=";C:\ProgramData\chocolatey\bin" # Package management is nice.
22 # $ENV:PATH+=";C:\PENGUIN" # Flag to ensure my profile kicked in.
23 #}
24
25 $env:Journal = "~\Journal\2021" # allows cd $env:journal
26
27 $src = "~"
28 if($IsWindows){
29 $src = "c:\src"
30 }
31
32 # Import some home grown PowerShell modules, if they are installed.
33 #
34 $modPaths = Get-Childitem -Path "$src\dotfiles\psmodules"
35 $modPaths += Get-Childitem -Path "$src\minion\psmodule"
36 if($IsWindows){
37 $modPaths += Get-Childitem -Path "$src\dotfiles\win_psmodules"
38 }
39 if($modPaths.length -eq 0){
40 Write-Host "No modules found."
41 }
42 $modPaths | ForEach-Object {
43 $fileName = $_.FullName
44 Import-Module $fileName
45 Write-Host ">> Loaded $fileName"
46 }
47
48 # $env:PSModulePath = $env:PSModulePath + ";$src\dotfiles\psmodules"
49
50 # Windows Only Modules
51
52
53 # Linux-like up/down in shell
54 Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
55 Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
56 Set-PSReadlineOption -HistorySavePath $src\PSHistory.log
57
58 # Minion alias commands - 'today'
59 . $src\minion\profiles\alias.ps1
60 # Add Minion to path
61 Write-Host "+ Added minion command to path."
62 $ENV:PATH+=";$src\minion\go" # Flag to ensure my profile kicked in.
63
64 # Unix dies hard.
65 New-Alias which get-command
66
67 # Delay loading PoshGit for speed.
68 function Enable-PoshGit {
69 Import-Module posh-git
70 }
71 New-Alias pg Enable-PoshGit
72 Write-Host "+ Type 'pg' to enable PoshGit"
73
74
75 if((Get-Location).Path -eq $HOME){
76 cd $src
77 }