]> us-delaporte.pagekite.me Git - dotfiles.git/blob - Microsoft.PowerShell_profile.ps1
7f228624c3a2529febeeda966821165986b1e19f
[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($modPaths.length -eq 0){
37 Write-Host "No modules found."
38 }
39 $modPaths | ForEach-Object {
40 $fileName = $_.FullName
41 Import-Module $fileName
42 Write-Host ">> Loaded $fileName"
43 }
44
45 # $env:PSModulePath = $env:PSModulePath + ";$src\dotfiles\psmodules"
46
47
48 # Linux-like up/down in shell
49 Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
50 Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
51 Set-PSReadlineOption -HistorySavePath c:\temp\PSHistory.log
52
53 # Minion alias commands - 'today'
54 . $src\minion\profiles\alias.ps1
55 # Add Minion to path
56 Write-Host "+ Added minion command to path."
57 $ENV:PATH+=";$src\minion\go" # Flag to ensure my profile kicked in.
58
59 # Unix dies hard.
60 New-Alias which get-command
61
62 # Delay loading PoshGit for speed.
63 function Enable-PoshGit {
64 Import-Module posh-git
65 }
66 New-Alias pg Enable-PoshGit
67 Write-Host "+ Type 'pg' to enable PoshGit"
68
69
70 if((Get-Location).Path -eq $HOME){
71 cd $src
72 }