-
Notifications
You must be signed in to change notification settings - Fork 2
/
pwsh-profile.ps1
111 lines (92 loc) · 2.83 KB
/
pwsh-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
# Load the Terminal icons module.
Import-Module -Name Terminal-Icons
# Load and configure the PowerShell history.
Import-Module -Name PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
# Start Oh My Posh.
oh-my-posh prompt init pwsh --config "$env:MY_ENV\ohmyposh.json" | Invoke-Expression
# Define some aliases for common tools and commands.
Set-Alias -Name he -Value helm
Set-Alias -Name d -Value docker
Set-Alias -Name k -Value kubectl
Set-Alias -Name g -Value git
Set-Alias -Name t -Value terraform
Set-Alias -Name vi -Value vim
Set-Alias -Name l -Value Get-ChildItem
Set-Alias -Name ll -Value Get-ChildItem
Set-Alias -Name kctx -Value kubectx
Set-Alias -Name kns -Value kubens
# Use this function to clone a repository quickly.
Function gcl {
param(
[string] $Url
)
git clone $Url
}
# Return Git status.
Function gs {
git status
}
# Use this function to apply a Kubernetes recipe to the current context.
Function kaf {
param(
[string] $File
)
k apply -f $File
}
# Get all pods in all namespaces or in the specified namespace.
Function kgp {
param(
[string] $Namespace = $null
)
if ($Namespace -eq $null) {
k get pods -A
}
else {
k get pods -n $Namespace
}
}
# Use this function to get a deployment details
Function kgd {
param(
[string] $Deployment,
[string] $Namespace = "default"
)
k get deployment -n $Namespace $Deployment
}
# Use this function to add, commit and push changes quickly.
Function gcoph {
param(
[string] $CommitMessage = "changes"
)
git add -A
git commit -am $CommitMessage
if ($LASTEXITCODE -eq 0) {
git push
}
}
# Refresh Kubernetes credentials.
Function kcreds {
param(
[string] $ResourceGroup = "kubernetes",
[string] $KubernetesCluster = "glzbcrt"
)
az aks get-credentials -g $ResourceGroup -n $KubernetesCluster --overwrite-existing
}
# Load Visual Studio 2022 environment.
Function vs {
Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstanceId 933f0d0b -Arch amd64 -HostArch amd64
}
# CTRL+B: open the current directory in Explorer.
Set-PSReadLineKeyHandler -Chord Ctrl+b -ScriptBlock {
"explorer.exe $pwd" | Invoke-Expression
}
# CTRL+G: navigate to the projects directory.
Set-PSReadLineKeyHandler -Chord Ctrl+g -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("cd $env:DEV_ROOT\projects")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}