]> apps.delaporte.us Git - dotfiles.git/blob - Microsoft.PowerShell_profile.ps1
Tip about PL fonts
[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 = "~\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 $ENV:PATH+=";$env:src\x16-demo\tools" # x16 python tools
33 $ENV:PATH+=";$env:src\chart" # command line chart utility edthedev\chart
34 }
35 else {
36 $ENV:PATH+=":$HOME/x16/x16-emulator" # x16 Emulator
37 $ENV:PATH+=":$HOME/src/x16-demo/tools" # x16 python tools
38 }
39 # alias renumber $HOME/src/x16-demo/
40
41 $env:Journal = "~\Journal\2021" # allows cd $env:journal
42 $env:minion = "$env:src\minion"
43
44 # Import some home grown PowerShell modules, if they are installed.
45 #
46 $modPaths = Get-Childitem -Path "$env:src\dotfiles\psmodules"
47 $modPaths += Get-Childitem -Path "$env:minion\psmodule"
48
49 # https://github.com/uillinois-community/powershell-scripts
50 $modPaths += Get-Childitem -Path "$env:src\powershell-scripts\modules"
51
52 # Windows Only Modules
53 if($IsWindows){
54 $modPaths += Get-Childitem -Path "$env:src\dotfiles\win_psmodules"
55 }
56 if($modPaths.length -eq 0){
57 Write-Host "No modules found."
58 }
59 $modPaths | ForEach-Object {
60 $fileName = $_.FullName
61 if($filename -Like "*.psm1") {
62 Import-Module $fileName
63 Write-Host ">> Loaded $fileName"
64 }
65 }
66
67
68
69 # Linux-like up/down in shell
70 Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
71 Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
72 Set-PSReadlineOption -HistorySavePath $env:src\PSHistory.log
73
74 # Minion alias commands - 'today'
75 # . C:\src\minion\profiles\alias.ps1
76 . $env:minion\profiles\alias.ps1
77 # Add Minion go executable to path.
78 . $env:minion\profiles\path.ps1
79 # Add Minion to path
80 Write-Host "+ Added minion command to path."
81 if($IsWindows){
82 $ENV:PATH+=";$env:minion\go" # Flag to ensure my profile kicked in.
83 }
84
85 # Unix dies hard.
86 New-Alias which get-command
87
88 # Delay loading PoshGit for speed.
89 function Enable-PoshGit {
90 Import-Module posh-git
91 }
92 New-Alias pg Enable-PoshGit
93 Write-Host "+ Type 'pg' to enable PoshGit"
94
95 function Invoke-X16Emu {
96 param(
97 [string]$File
98 )
99 x16emu.exe -bas $File -keymap en-us
100 }
101
102 New-Alias x16 Invoke-X16Emu
103
104 if((Get-Location).Path -eq $HOME){
105 cd $env:src
106 }
107
108 function Get-GitLog() {
109 git log --oneline
110 }
111
112 function Get-GitStatus() {
113 git status -b --short
114 }
115
116 # Tell my scripts which GitHub repositories to look in.
117 $env:GITHUB_USERNAME = 'edthedev'
118 $env:GITHUB_ORG = 'techservicesillinois'
119 $env:GITHUB_ORGS = @('techservicesillinois', 'uillinois-community')
120 $env:GITHUB_REPOS = @(
121 'techservicesillinois/SecOps-Tools',
122 'techservicesillinois/secdev-job-aids',
123 'techservicesillinois/awscli-login',
124 'techservicesillinois/farmit',
125 'uillinois-community/uillinois-community.github.io'
126 )
127
128 # Nice for git
129 New-Alias ol Get-GitLog
130 New-Alias st Get-GitStatus
131
132 # Dashboard
133 New-Alias dash Show-MyDashboard # from dash.psm1
134 New-Alias agenda Get-JournalAgenda # from minion_go.psm1