66 lines
1.7 KiB
Cheetah
66 lines
1.7 KiB
Cheetah
{{ if eq .bash.prompt.type "oh-my-posh" }}
|
|
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\atomic.omp.json" | Invoke-Expression
|
|
{{ end }}
|
|
|
|
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
|
|
}
|
|
|
|
# History with search
|
|
function hist {
|
|
$find = $args
|
|
Write-Host "Finding in full history using {`$_ -like `"*$find*`"}"
|
|
Get-Content (Get-PSReadlineOption).HistorySavePath | ? {$_ -like "*$find*"} | Get-Unique | more
|
|
}
|
|
# Reverse History Search
|
|
# Found at https://stackoverflow.com/questions/62883762/powershell-bind-arrow-keys-to-command-history-search
|
|
#
|
|
# Set-PSReadlineKeyHandler will list all mapped keys
|
|
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
|
|
Set-PSReadlineKeyHandler -Key PageUp -Function HistorySearchBackward
|
|
Set-PSReadlineKeyHandler -Key PageDown -Function HistorySearchForward
|
|
|
|
# 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
|
|
Set-Alias ll dir
|
|
|
|
function gg {
|
|
git graph
|
|
}
|
|
|
|
{{ if eq .bash.prompt.type "starship" }}
|
|
Invoke-Expression (&starship init powershell)
|
|
{{ end }}
|