]> us-delaporte.pagekite.me Git - dotfiles.git/blob - Microsoft.PowerShell_profile.ps1
Clearer filename
[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:\bin\x16emu" # Package management is nice.
30 $ENV:PATH+=";C:\Program Files (x86)\GnuWin32\bin" # GNU Utils - i.e. rm
31 $ENV:PATH+=";C:\PENGUIN" # Flag to ensure my profile kicked in.
32 }
33
34
35 $env:Journal = "~\Journal\2021" # allows cd $env:journal
36 $env:minion = "$env:src\minion"
37
38 # Import some home grown PowerShell modules, if they are installed.
39 #
40 $modPaths = Get-Childitem -Path "$env:src\dotfiles\psmodules"
41 $modPaths += Get-Childitem -Path "$env:minion\psmodule"
42
43 # Windows Only Modules
44 if($IsWindows){
45 $modPaths += Get-Childitem -Path "$env:src\dotfiles\win_psmodules"
46 }
47 if($modPaths.length -eq 0){
48 Write-Host "No modules found."
49 }
50 $modPaths | ForEach-Object {
51 $fileName = $_.FullName
52 Import-Module $fileName
53 Write-Host ">> Loaded $fileName"
54 }
55
56
57
58 # Linux-like up/down in shell
59 Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
60 Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
61 Set-PSReadlineOption -HistorySavePath $env:src\PSHistory.log
62
63 # Minion alias commands - 'today'
64 # . C:\src\minion\profiles\alias.ps1
65 . $env:minion\profiles\alias.ps1
66 # Add Minion go executable to path.
67 . $env:minion\profiles\path.ps1
68 # Add Minion to path
69 Write-Host "+ Added minion command to path."
70 $ENV:PATH+=";$env:minion\go" # Flag to ensure my profile kicked in.
71
72 # Unix dies hard.
73 New-Alias which get-command
74
75 # Delay loading PoshGit for speed.
76 function Enable-PoshGit {
77 Import-Module posh-git
78 }
79 New-Alias pg Enable-PoshGit
80 Write-Host "+ Type 'pg' to enable PoshGit"
81
82 function Invoke-X16Emu {
83 param(
84 [string]$File
85 )
86 x16emu.exe -bas $File -keymap en-us
87 }
88
89 New-Alias x16 Invoke-X16Emu
90
91 if((Get-Location).Path -eq $HOME){
92 cd $env:src
93 }
94
95 function Get-GitLog() {
96 git log --oneline
97 }
98
99 function Get-GitStatus() {
100 git status -b --short
101 }
102
103 # Nice for git
104 New-Alias ol Get-GitLog
105 New-Alias st Get-GitStatus
106
107 # Dashboard
108 New-Alias dash Get-MyDashboard # from dash.psm1
109 New-Alias agenda Get-JournalAgenda # from minion_go.psm1