-
Notifications
You must be signed in to change notification settings - Fork 0
/
Microsoft.PowerShell_profile.ps1
198 lines (167 loc) · 6.37 KB
/
Microsoft.PowerShell_profile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# Chocolatey required
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
oh-my-posh init pwsh --config ~\Documents\PowerShell\powerUser\mytheme.omp.json | Invoke-Expression
Import-Module -Name Terminal-Icons
# For zoxide v0.8.0+
Invoke-Expression (& {
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
(zoxide init --hook $hook powershell | Out-String)
})
#Change 'z' to 'cd' if you aren't using that module and put in an absolute path
#Best to use these commands if you aren't already in the local-dev directory
function firstTimeWingetInstall {
Install-Module Terminal-Icons
$packages = @(
'Git.Git',
'GitHub.cli',
'junegunn.fzf',
'ajeetdsouza.zoxide'
'7zip.7zip',
'sharkdp.bat',
'sharkdp.fd',
'CoreyButler.NVMforWindows',
'Microsoft.PowerToys',
'JanDeDobbeleer.OhMyPosh',
'suse.RancherDesktop',
'Chocolatey.Chocolatey'
)
foreach ($package in $packages) {
winget install $package
}
}
function firstTimeChocoInstall {
$packages = @(
'pyenv-win'
)
foreach ($package in $packages) {
choco install $package -y
}
}
function configureNuShell {
$nuShellConfigPath = "$env:APPDATA\nushell"
$envNuPath = Join-Path -Path $nuShellConfigPath -ChildPath "env.nu"
$configNuPath = Join-Path -Path $nuShellConfigPath -ChildPath "config.nu"
if (Test-Path -Path $envNuPath -PathType Leaf) { # just checking env.nu is enough
# as per https://github.com/ajeetdsouza/zoxide#:~:text=Ksh-,Nushell,-PowerShell
# as per https://ohmyposh.dev/docs/installation/prompt#:~:text=fish-,nu,-powershell
zoxide init nushell >> ~/.zoxide.nu
oh-my-posh init nu
"`nzoxide init nushell | save -f ~/.zoxide.nu" | Out-File -Append -FilePath $envNuPath
"oh-my-posh init nu" | Out-File -Append -FilePath $envNuPath
"`nsource ~/.zoxide.nu" | Out-File -Append -FilePath $configNuPath
"source ~/.oh-my-posh.nu" | Out-File -Append -FilePath $configNuPath
} else {
Write-Output "One or both of env.nu and config.nu do not exist in $nuShellConfigPat. Is NuShell installed?"
}
}
function updateOhMyPosh { winget upgrade JanDeDobbeleer.OhMyPosh -s winget }
#POWERSHELL
function updatePowerShell {winget upgrade --id Microsoft.Powershell --source winget}
function profile {Get-Content "~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1"}
function copyProfile($updateRemote) {
$localProfile = "~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1"
$remoteProfile = "~\Documents\PowerShell\powerUser\Microsoft.PowerShell_profile.ps1"
$toBeReplaced = ""
$recentlyUpdated = ""
if ([bool]$updateRemote) {
$toBeReplaced = $remoteProfile
$recentlyUpdated = $localProfile
} else {
$toBeReplaced = $localProfile
$recentlyUpdated = $remoteProfile
}
$client = Select-String -Path $recentlyUpdated -Pattern "# CLIENT"
if (($client.LineNumber)[1] -gt 0) {
$clientSectionStartingLine = ($client.LineNumber)[1]
$nonClientCode = Get-Item -Path $recentlyUpdated | Get-Content -Head ($clientSectionStartingLine - 1)
} else {
$nonClientCode = Get-Item -Path $recentlyUpdated | Get-Content
}
$nonClientCode | Out-File $toBeReplaced
}
function getDef($func) {(Get-Command $func).Definition}
function open {explorer .}
function path($file) {Get-Item $file | Select-Object FullName}
function ch {[Microsoft.PowerShell.PSConsoleReadLine]::ClearHistory()}
function getPublicIP {(Invoke-WebRequest ifconfig.me/ip).Content.Trim()}
function wifiPass($SSID) {netsh wlan show profile name=$SSID key=clear}
#END POWERSHELL
#DOCKER
# https://docs.docker.com/engine/reference/commandline/cli/
function dv {docker compose down -v}
function up {docker compose up}
function bup {docker compose up --build}
function rebup($containerName) {docker compose build $containerName --no-cache && docker compose up -d}
function bnc {docker compose build --no-cache}
function buildall {docker compose build}
function build($containerName) {docker compose build $containerName}
function vbup {docker compose down -v && docker compose build --no-cache && docker compose up}
function prune {docker system prune}
#END DOCKER
#JIRA CLI
# https://github.com/ankitpokhrel/jira-cli#usage
function jList { jira sprint list --current -ax --columns "Key,Summary" }
function jMine { jira sprint list --current -a(jira me) --columns "Key,Summary,Status" }
function jFixVersion($fixVersion) {
$tickets = jira sprint list --current -a(jira me) --plain --no-headers --columns "Key"
foreach ($ticket in $tickets) {
jira issue edit $ticket --fix-version $fixVersion --no-input
}
}
function jAssign($issueName) {jira issue assign $issueName $(jira me)}
function jIssue { $Env:CURRENT_ISSUE_NAME }
function jSet($newIssue) {
[Environment]::SetEnvironmentVariable("CURRENT_ISSUE_NAME", $newIssue, [System.EnvironmentVariableTarget]::User) `
&& refreshenv
# refreshenv is from Chocolatey
}
function jView($issueName) {
if ([bool]$issueName) {
jira issue view $issueName
} else {
jira issue view $Env:CURRENT_ISSUE_NAME
}
}
function jMove($newState, $issueName) {
if ([bool]$issueName) {
jira issue move $issueName $newState
} else {
jira issue move $Env:CURRENT_ISSUE_NAME $newState
}
}
function jInProg($issueName) {
if ([bool]$issueName) {
jira issue move $issueName "In Progress"
} else {
jira issue move $Env:CURRENT_ISSUE_NAME "In Progress"
}
}
function jReview($issueName) {
if ([bool]$issueName) {
jira issue move $issueName "Code Review"
} else {
jira issue move $Env:CURRENT_ISSUE_NAME "Code Review"
}
}
function jDone($issueName) {
if ([bool]$issueName) {
jira issue move $issueName Done
} else {
jira issue move $Env:CURRENT_ISSUE_NAME Done
}
}
#END JIRA CLI
function combinePDFs {magick -density 150 $(Get-ChildItem *pdf) output.pdf}
function restore {dotnet restore --interactive}
function nup {npm run start}
function ghidra {& "C:\Program Files\ghidra\ghidraRun.bat"}
#GIT
function wt($branchName) {git worktree add -b $branchName $branchName}
function apply {
git stash show -p | git apply
}
function reverse {
git stash show -p | git apply -R
}
#END GIT