From dba0c78c6b7d7e5f4f543527f987322215191ab2 Mon Sep 17 00:00:00 2001 From: Heavy Date: Fri, 5 Jul 2024 11:17:19 +0200 Subject: [PATCH] (powershell): Add powershell profile as template. --- .../Microsoft.PowerShell_profile.ps1.tmpl | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl diff --git a/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl b/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl new file mode 100644 index 0000000..7362617 --- /dev/null +++ b/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl @@ -0,0 +1,40 @@ +oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\atomic.omp.json" | Invoke-Expression + +function Get-LastN { + param ( + [Parameter(Position=0)] + [int]$days = -7 + ) + Get-ChildItem -Path . -Recurse| ? {$_.LastWriteTime -gt (Get-Date).AddDays($days)} +} + +# Using positional parameters +# See https://www.sharepointdiary.com/2021/02/powershell-function-parameters.html +function Net-Cat() { + param ( + [Parameter(Position=0)] + [string]$computerName = "localhost", + [Parameter(Position=1)] + [int]$port = 22 + ) + + Test-NetConnection -ComputerName $computerName -Port $port -InformationLevel Detailed +} + +# Navigate one directory up +function Go-One-Level-Up { + cd .. +} +# Navigate two directories up +function Go-Two-Levels-Up { + cd .. + cd .. +} + +# Set alias for navigation functions +Set-Alias .. Go-One-Level-Up +Set-Alias ... Go-Two-Levels-Up + +# More Aliases +Set-Alias vi nvim +Set-Alias vim nvim