Skip to content

Instantly share code, notes, and snippets.

@dorlugasigal
Last active February 7, 2025 00:33
Show Gist options
  • Select an option

  • Save dorlugasigal/491cb79eb5e02a011c5ee22a0e334fc2 to your computer and use it in GitHub Desktop.

Select an option

Save dorlugasigal/491cb79eb5e02a011c5ee22a0e334fc2 to your computer and use it in GitHub Desktop.
my PowerShell $PROFILE imports
#### user interface ####
Import-Module Terminal-Icons
oh-my-posh --init --shell pwsh --config 'C:\Users\dorlugasigal\OhMyPoshThemes\dlg.omp.json' | Invoke-Expression
#### common aliases ####
Set-Alias g git
Set-Alias vim nvim
Set-Alias vi nvim
Set-Alias ll ls
Set-Alias grep findstr
### kubectl commands ###
Set-Alias k kubectl
Set-Alias -Name kgp -Value GetPods
Set-Alias -Name kgpw -Value GetPodsWide
Set-Alias -Name kgall -Value GetAll
Set-Alias -Name kgn -Value GetNodes
Set-Alias -Name kgs -Value GetServices
Set-Alias -Name kdp -Value DescribePod
Set-Alias -Name klp -Value GetLogs
Set-Alias -Name kaf -Value ApplyYaml
Set-Alias -Name kexec -Value ExecContainerShell
#### auto complete && suggestions #####
## fuck
$env:PYTHONIOENCODING="utf-8"
iex "$(thefuck --alias)"
Import-Module PSReadLine
Enable-PowerType
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
###### searching #######
Import-Module PSFzf
Set-PsFzfOption -PSReadLineChordProvider 'Ctrl+f' -PSReadLineChordReverseHistory 'Ctrl+r'
### dotnet shortcuts ###
Set-PSReadLineKeyHandler -Key Ctrl+Shift+b `
-BriefDescription BuildCurrentDirectory `
-LongDescription "Build the current directory" `
-ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("dotnet build")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
Set-PSReadLineKeyHandler -Key Ctrl+Shift+t `
-BriefDescription BuildCurrentDirectory `
-LongDescription "Build the current directory" `
-ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("dotnet test")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
Set-PSReadLineKeyHandler -Key Ctrl+Shift+r `
-BriefDescription BuildCurrentDirectory `
-LongDescription "Restore nuget packages of the current directory" `
-ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("dotnet restore")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
### functions definitions ###
function GetPods([string]$namespace="default")
{
kubectl get pods -n $namespace
}
function GetPodsWide([string]$namespace="default")
{
kubectl get pods -n $namespace -o wide
}
function GetAll([string]$namespace="default")
{
kubectl get all -n $namespace
}
function GetNodes()
{
kubectl get nodes -o wide
}
function DescribePod([string]$container, [string]$namespace="default")
{
kubectl describe po $container -n $namespace
}
function GetLogs([string]$container, [string]$namespace="default")
{
kubectl logs pod/$container -n $namespace
}
function ApplyYaml([string]$filename)
{
kubectl apply -f $filename
}
function ExecContainerShell([string]$container, [string]$namespace="default")
{
kubectl exec -it $container -n $namespace — sh
}
function GetServices([string]$namespace="default")
{
kubectl get services -n $namespace
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment