]> apps.delaporte.us Git - dotfiles.git/blob - files/Microsoft.PowerShell_profile.ps1
Move cheatsheets to doc
[dotfiles.git] / files / Microsoft.PowerShell_profile.ps1
1 #WebDriverException: Message: unknown error: cannot determine loading status .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+=";$env:src\bin" # anything else I need
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:\bin\x16emu" # Package management is nice.
23 $ENV:PATH+=";C:\Program Files (x86)\GnuWin32\bin" # GNU Utils - i.e. rm
24 $ENV:PATH+=";C:\PENGUIN" # Flag to ensure my profile kicked in.
25 $ENV:PATH+=";$env:src\x16-demo\tools" # x16 python tools
26 $ENV:PATH+=";$env:src\flutter\bin" # Flutter for Dart
27 }
28 else {
29 $ENV:PATH+=";$env:src/bin" # anything else I need
30 $ENV:PATH+=":$HOME/x16/x16-emulator" # x16 Emulator
31 $ENV:PATH+=":$HOME/src/x16-demo/tools" # x16 python tools
32 }
33
34 # Command line tools
35 $ENV:PATH+=";$env:src\chart" # command line chart utility edthedev\chart
36 $ENV:PATH+=";$env:src\agenda" # command line chart utility edthedev\chart
37 $ENV:PATH+=";$env:src\todolist" # todo list utility edthedev\todolist
38 $env:todolist = "C:\Users\delaport\Journal\"
39 # New-Alias todo todolist
40
41 # alias renumber $HOME/src/x16-demo/
42
43 $env:Journal = "~\Journal" # allows cd $env:journal
44 $env:minion = "$env:src\minion"
45
46 # Import some home grown PowerShell modules, if they are installed.
47 #
48 $modPaths = Get-Childitem -ErrorAction Ignore -Path "$env:src\dotfiles\psmodules"
49 $modPaths += Get-Childitem -ErrorAction Ignore -Path "$env:minion\psmodule"
50
51 # https://github.com/uillinois-community/powershell-scripts
52 $modPaths += Get-Childitem -ErrorAction Ignore -Path "$env:src\powershell-scripts\modules"
53
54 # Windows Only Modules
55 if($IsWindows){
56 $modPaths += Get-Childitem -ErrorAction Ignore -Path "$env:src\dotfiles\win_psmodules"
57 }
58 if($modPaths.length -eq 0){
59 Write-Host "No modules found."
60 }
61 $modPaths | ForEach-Object {
62 $fileName = $_.FullName
63 if($filename -Like "*.psm1") {
64 Import-Module $fileName
65 Write-Host ">> Loaded $fileName"
66 }
67 }
68
69
70
71 # Linux-like up/down in shell
72 Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
73 Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
74 Set-PSReadlineOption -HistorySavePath $env:src\PSHistory.log
75
76 # Minion alias commands - 'today'
77 # . C:\src\minion\profiles\alias.ps1
78 # . $env:minion\profiles\alias.ps1
79 # Add Minion go executable to path.
80 # . $env:minion\profiles\path.ps1
81 # Add Minion to path
82 # Write-Host "+ Added minion command to path."
83 # if($IsWindows){
84 # $ENV:PATH+=";$env:minion\go" # Flag to ensure my profile kicked in.
85 # }
86
87 # Unix dies hard.
88 New-Alias which get-command
89
90 # Delay loading PoshGit for speed.
91 function Enable-PoshGit {
92 Import-Module posh-git
93 }
94 New-Alias pg Enable-PoshGit
95 Write-Host "+ Type 'pg' to enable PoshGit"
96
97 function Invoke-X16Emu {
98 param(
99 [string]$File
100 )
101 x16emu.exe -bas $File -keymap en-us
102 }
103
104 New-Alias x16 Invoke-X16Emu
105
106 if((Get-Location).Path -eq $HOME){
107 cd $env:src
108 }
109
110 function Get-GitLog() {
111 git log --oneline
112 }
113
114 function Get-GitStatus() {
115 git status -b --short
116 }
117
118 # Tell my scripts which GitHub repositories to look in.
119 $env:GITHUB_USERNAME = 'edthedev'
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 'techservicesillinois/SecOps-Powershell-CSOC',
127 'techservicesillinois/SecOps-Powershell-CISDSC',
128 'techservicesillinois/secops-splunk-null-router'
129 ) -join ' '
130 $ENV:TS_REPOS = $ENV:GITHUB_REPOS.split(' ') | Where { $_ -like 'techser*' }
131
132
133 # Nice for git
134 New-Alias ol Get-GitLog
135 New-Alias st Get-GitStatus
136
137 # Dashboard
138 New-Alias dash Show-MyDashboard # from dash.psm1
139
140 function Get-JournalAgenda() {
141 agenda.exe -path "$HOME/Journal/{YYYY}/{MM}-{DD}.md"
142 }
143 New-Alias today Get-JournalAgenda
144
145 function Invoke-FixWslVPN {
146 Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect Secure Mobility Client Virtual Miniport Adapter for Windows x64"} | Set-NetIPInterface -InterfaceMetric 6000
147 }