-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.ps1
105 lines (88 loc) · 3.22 KB
/
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
#Requires -Version 7
# requirements
# - install oh-my-posh: winget install JanDeDobbeleer.OhMyPosh
# - fzf first: https://github.com/junegunn/fzf/releases
# - install fonts: https://github.com/ryanoasis/nerd-fonts/releases/
if (!(Get-Module Terminal-Icons -ListAvailable)) {
Install-Module Terminal-Icons
}
Import-Module Terminal-Icons
# install fzf first
if (!(Get-Module PSFzf -ListAvailable)) {
Install-Module -Name PSFzf
}
Import-Module PSFzf
# install PSReadLine
if (!(Get-Module PSReadLine -ListAvailable)) {
Install-Module PSReadLine -AllowPrerelease -Force
}
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
# install posh-git
if (!(Get-Module posh-git -ListAvailable)) {
Install-Module posh-git -Scope CurrentUser -Force
}
Import-Module posh-git
$modulesPath = Join-Path -Path ~ -ChildPath "projects\github.com\Ne4to\scripts\modules"
if (-not (Test-Path $modulesPath)) {
$modulesPath = Join-Path -Path ~ -ChildPath "projects\GitHub\Ne4to\scripts\modules"
}
if (Test-Path $modulesPath) {
Get-ChildItem $modulesPath -Filter *.psm1 -Recurse |
ForEach-Object {
Import-Module $_.FullName
}
}
# if (Test-Path "$($ThemeSettings.MyThemesLocation)\*") {
# Get-ChildItem -Path "$($ThemeSettings.MyThemesLocation)\*" -Include '*.psm1'
# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
dotnet complete --position $cursorPosition "$wordToComplete" |
ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
# setup kubectl aliases
if (Test-Path $Home\projects\github.com\Ne4to\scripts\kubectl_aliases.ps1) {
. $Home\projects\github.com\Ne4to\scripts\kubectl_aliases.ps1
}
if (Test-Path $Home\projects\GitHub\Ne4to\scripts\kubectl_aliases.ps1) {
. $Home\projects\GitHub\Ne4to\scripts\kubectl_aliases.ps1
}
function krrd() { & kubectl rollout restart deployment $args }
function kksd() { & kubectl ksddotnet get secret -oyaml $args }
function time {
Param([ScriptBlock]$cmd)
Measure-Command { . $cmd | Out-Default } |
Select-Object TotalSeconds
}
function watch {
Param(
[ScriptBlock]$cmd,
[int]$Seconds = 1
)
while ($true) {
. $cmd | Out-Default
Write-Host
Start-Sleep -Seconds $Seconds
}
}
function cpwd {
Get-Location | Set-Clipboard
}
function dockerps {
docker ps --format 'table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Ports}}'
}
function dockerpsa {
docker ps -a --format 'table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Ports}}'
}
# setup oh-my-posh
if (Test-Path $Home\projects\GitHub\Ne4to\scripts\jandedobbeleer.omp.json) {
oh-my-posh --init --shell pwsh --config $Home\projects\GitHub\Ne4to\scripts\jandedobbeleer.omp.json | Invoke-Expression
}
if (Test-Path $Home\projects\github.com\Ne4to\scripts\jandedobbeleer.omp.json) {
oh-my-posh --init --shell pwsh --config $Home\projects\github.com\Ne4to\scripts\jandedobbeleer.omp.json | Invoke-Expression
}
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'