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