]> us-delaporte.pagekite.me Git - dotfiles.git/blob - Microsoft.PowerShell_profile.ps1
Tweaks
[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 $env:src = "~\src"
12 if($IsWindows){
13 $env:src = "c:\src"
14 }
15
16 if($IsWindows){
17 # Some Paths that are annoying to find/restore if the installer fails
18 $ENV:PATH+=";C:\Program Files\Microsoft VS Code\bin" # One Editor to rule them all
19 $ENV:PATH+=";C:\Program Files\Git\cmd" # Version control is nice.
20 $ENV:PATH+=";C:\ProgramData\chocolatey\bin" # Package management is nice.
21 $ENV:PATH+=";C:\bin\x16emu" # Package management is nice.
22 $ENV:PATH+=";C:\Program Files (x86)\GnuWin32\bin" # GNU Utils - i.e. rm
23 $ENV:PATH+=";C:\PENGUIN" # Flag to ensure my profile kicked in.
24 $ENV:PATH+=";$env:src\x16-demo\tools" # x16 python tools
25 $ENV:PATH+=";$env:src\chart" # command line chart utility edthedev\chart
26 }
27 else {
28 $ENV:PATH+=":$HOME/x16/x16-emulator" # x16 Emulator
29 $ENV:PATH+=":$HOME/src/x16-demo/tools" # x16 python tools
30 }
31
32 # alias renumber $HOME/src/x16-demo/
33
34 $env:Journal = "~\Journal\2022" # allows cd $env:journal
35 $env:minion = "$env:src\minion"
36
37 # Import some home grown PowerShell modules, if they are installed.
38 #
39 $modPaths = Get-Childitem -ErrorAction Ignore -Path "$env:src\dotfiles\psmodules"
40 $modPaths += Get-Childitem -ErrorAction Ignore -Path "$env:minion\psmodule"
41
42 # https://github.com/uillinois-community/powershell-scripts
43 $modPaths += Get-Childitem -ErrorAction Ignore -Path "$env:src\powershell-scripts\modules"
44
45 # Windows Only Modules
46 if($IsWindows){
47 $modPaths += Get-Childitem -ErrorAction Ignore -Path "$env:src\dotfiles\win_psmodules"
48 }
49 if($modPaths.length -eq 0){
50 Write-Host "No modules found."
51 }
52 $modPaths | ForEach-Object {
53 $fileName = $_.FullName
54 if($filename -Like "*.psm1") {
55 Import-Module $fileName
56 Write-Host ">> Loaded $fileName"
57 }
58 }
59
60
61
62 # Linux-like up/down in shell
63 Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
64 Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
65 Set-PSReadlineOption -HistorySavePath $env:src\PSHistory.log
66
67 # Minion alias commands - 'today'
68 # . C:\src\minion\profiles\alias.ps1
69 # . $env:minion\profiles\alias.ps1
70 # Add Minion go executable to path.
71 # . $env:minion\profiles\path.ps1
72 # Add Minion to path
73 # Write-Host "+ Added minion command to path."
74 # if($IsWindows){
75 # $ENV:PATH+=";$env:minion\go" # Flag to ensure my profile kicked in.
76 # }
77
78 # Unix dies hard.
79 New-Alias which get-command
80
81 # Delay loading PoshGit for speed.
82 function Enable-PoshGit {
83 Import-Module posh-git
84 }
85 New-Alias pg Enable-PoshGit
86 Write-Host "+ Type 'pg' to enable PoshGit"
87
88 function Invoke-X16Emu {
89 param(
90 [string]$File
91 )
92 x16emu.exe -bas $File -keymap en-us
93 }
94
95 New-Alias x16 Invoke-X16Emu
96
97 if((Get-Location).Path -eq $HOME){
98 cd $env:src
99 }
100
101 function Get-GitLog() {
102 git log --oneline
103 }
104
105 function Get-GitStatus() {
106 git status -b --short
107 }
108
109 # Tell my scripts which GitHub repositories to look in.
110 $env:GITHUB_USERNAME = 'edthedev'
111 $env:GITHUB_REPOS = @(
112 'techservicesillinois/SecOps-Tools',
113 'techservicesillinois/secdev-job-aids',
114 'techservicesillinois/awscli-login',
115 'techservicesillinois/farmit',
116 'uillinois-community/uillinois-community.github.io',
117 'techservicesillinois/SecOps-Powershell-CSOC',
118 'techservicesillinois/SecOps-Powershell-CISDSC'
119 ) -join ' '
120 $ENV:TS_REPOS = $ENV:GITHUB_REPOS.split(' ') | Where { $_ -like 'techser*' }
121
122 # Todo List
123 $ENV:PATH+=";$env:src\todolist" # todo list utility edthedev\todolist
124 $env:todolist = "C:\Users\delaport\Journal\2022"
125 # New-Alias todo todolist
126
127 # Nice for git
128 New-Alias ol Get-GitLog
129 New-Alias st Get-GitStatus
130
131 # Dashboard
132 New-Alias dash Show-MyDashboard # from dash.psm1
133 New-Alias agenda Get-JournalAgenda # from minion_go.psm1
134
135 function Invoke-FixWslVPN {
136 Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect Secure Mobility Client Virtual Miniport Adapter for Windows x64"} | Set-NetIPInterface -InterfaceMetric 6000
137 }