208 lines
4.6 KiB
PowerShell
208 lines
4.6 KiB
PowerShell
oh-my-posh init pwsh --config "$HOME/.theme.omp.json" | Invoke-Expression
|
|
|
|
# git posh, seems to slow down things
|
|
# Import-Module posh-git
|
|
|
|
# setup fnm
|
|
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
|
|
|
|
function Set-Title {
|
|
param(
|
|
[string]$title
|
|
)
|
|
wezterm cli set-tab-title $title
|
|
}
|
|
Set-Alias -Name title -Value Set-Title
|
|
Set-Alias -Name python3 -Value python
|
|
|
|
function To-Gif {
|
|
param(
|
|
[string]$inputFilePath,
|
|
[string]$outputFilePath
|
|
)
|
|
ffmpeg -i $inputFilePath -vf "fps=10,scale=1080:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 $outputFilePath
|
|
}
|
|
|
|
|
|
# Functions
|
|
function d-up {
|
|
docker compose up --build -d
|
|
}
|
|
function d-bash {
|
|
docker exec -it "$1" /bin/bash
|
|
}
|
|
function d-down {
|
|
docker compose down -v
|
|
}
|
|
function d-down-up {
|
|
d-down
|
|
d-up
|
|
}
|
|
function d-logs {
|
|
docker compose logs -f -t
|
|
}
|
|
function d-ps {
|
|
docker compose ps -a
|
|
}
|
|
|
|
function cdli {
|
|
Set-Location "C:\repos\litium"
|
|
}
|
|
|
|
function cdsf {
|
|
Set-Location "C:\repos\storefront"
|
|
}
|
|
|
|
function cdsfdev {
|
|
cdsf
|
|
$cwd = (Get-Location).Path
|
|
$w = "wezterm"
|
|
$vimPane = $env:WEZTERM_PANE
|
|
|
|
function Send-Command($paneId, $cmd) {
|
|
& $w cli send-text --pane-id $paneId $cmd
|
|
& $w cli send-text --pane-id $paneId "`n"
|
|
}
|
|
|
|
Send-Command $vimPane "vim ."
|
|
|
|
$yarnPane = & $w cli split-pane --pane-id $vimPane --right --cwd $cwd
|
|
Start-Sleep -Milliseconds 300
|
|
Send-Command $yarnPane "yarn install && yarn dev"
|
|
|
|
$proxyPane = & $w cli split-pane --pane-id $yarnPane --bottom --cwd $cwd
|
|
Start-Sleep -Milliseconds 300
|
|
Send-Command $proxyPane ".\proxy-win.ps1"
|
|
|
|
$gitPane = & $w cli split-pane --pane-id $proxyPane --bottom --cwd $cwd
|
|
Start-Sleep -Milliseconds 300
|
|
Send-Command $gitPane "git status"
|
|
|
|
& $w cli activate-pane --pane-id $vimPane
|
|
}
|
|
|
|
function cdr {
|
|
Set-Location "C:\repos"
|
|
}
|
|
|
|
function proxy {
|
|
winget install caddy
|
|
& caddy 'C:\Users\ZackariasMontell\OneDrive - RevolutionRace\caddyfile'
|
|
}
|
|
|
|
function reset-card {
|
|
& "gpg-connect-agent" "killagent" "/bye"
|
|
& "gpg-connect-agent" "/bye"
|
|
& "gpg" "--card-status"
|
|
}
|
|
|
|
function card {
|
|
& "gpg" "--card-status"
|
|
}
|
|
|
|
function spot {
|
|
title ncspot
|
|
ncspot
|
|
}
|
|
|
|
function Open-KubernetesDashboard {
|
|
Write-Host "Ensuring doctl.."
|
|
if ($os -eq 'Unix') {
|
|
brew install doctl
|
|
}
|
|
else {
|
|
winget install DigitalOcean.Doctl
|
|
}
|
|
|
|
Write-Host "Checking your login status.."
|
|
$accountInfo = doctl account get
|
|
|
|
if ($null -eq $accountInfo) {
|
|
$token = Read-Host "You are not logged in, please enter your doctl token, you can create one here https://cloud.digitalocean.com/account/api/tokens"
|
|
doctl auth init -t $token
|
|
}
|
|
|
|
$cluster = Read-Host "What cluster do you want to connect to? staging or production (default: staging)"
|
|
|
|
if ($cluster -eq "production") {
|
|
$cluster = "production-cluster"
|
|
}
|
|
else {
|
|
$cluster = "staging-cluster"
|
|
}
|
|
|
|
Write-Host "Setting up kubectl context.."
|
|
doctl kubernetes cluster kubeconfig save $cluster
|
|
|
|
Write-Host "Generating token.."
|
|
$token = kubectl -n kubernetes-dashboard create token admin-user
|
|
Set-Clipboard -Value $token
|
|
Write-Host "Token copied to clipboard."
|
|
|
|
Write-Host "Opening Kubernetes dashboard.."
|
|
$url = "http://localhost:8080/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login"
|
|
|
|
Start-Process $url
|
|
|
|
Write-Host "Setting up port forwarding, close this when you are done.."
|
|
kubectl proxy --port 8080
|
|
}
|
|
|
|
function Open-Nuxt(){
|
|
cdsf
|
|
yarn
|
|
yarn dev
|
|
}
|
|
|
|
function Open-Notes(){
|
|
cdr
|
|
cd notes
|
|
title notes
|
|
vim
|
|
}
|
|
|
|
function Edit-Powershell(){
|
|
nvim $profile
|
|
. $profile
|
|
}
|
|
|
|
function Edit-Nvim(){
|
|
prev = (& pwd).Path
|
|
cd ~\AppData\Local\nvim
|
|
nvim .
|
|
cd prev
|
|
}
|
|
|
|
function Connect-Dev1(){
|
|
# Using wsl to forward ssh-agent and connect to vps
|
|
#ubuntu run 'sh /home/wholteza/.config/relay-ssh-agent.sh && mosh --ssh="-o ForwardAgent=yes" wholteza@dev1.zacke.dev'
|
|
ssh -o ForwardAgent=yes wholteza@dev1.zacke.dev
|
|
}
|
|
|
|
# Aliases
|
|
Set-alias -Name g -Value git
|
|
Set-Alias -Name k -Value kubectl
|
|
Set-Alias -Name d -Value docker
|
|
Set-Alias -Name do -Value doctl
|
|
Set-Alias -Name vim -Value nvim
|
|
Set-Alias -Name yy -Value Open-Nuxt
|
|
Set-Alias -Name dev1 -Value Connect-Dev1
|
|
|
|
Set-Alias -Name dash -Value Open-KubernetesDashboard
|
|
|
|
Set-Alias -Name cd-repos -Value cdr
|
|
Set-Alias -Name repos -Value cdr
|
|
Set-Alias -Name cd-sf -Value cdsf
|
|
Set-Alias -Name sf -Value cdsfdev
|
|
Set-Alias -Name cd-li -Value cdli
|
|
Set-Alias -Name li -Value cdli
|
|
|
|
Set-Alias -Name notes -Value Open-Notes
|
|
|
|
# Set up docker environment
|
|
#$Env:DOCKER_HOST="ssh://wholteza@localhost:22/"
|
|
|
|
# Set all files in .kube as kubeconfig paths.
|
|
# This allows for dynamic kubeconfig use.
|
|
$env:KUBECONFIG = (Get-ChildItem "$HOME\.kube" -File | ForEach-Object { $_.FullName }) -join ";"
|