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