(powershell): Add history function and prompt selection.

This commit is contained in:
Heavy 2025-06-09 17:33:31 +02:00
parent 16977202b9
commit a8e462e129

View File

@ -1,4 +1,6 @@
{{ 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 (
@ -21,6 +23,20 @@ function Net-Cat() {
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 ..
@ -38,3 +54,12 @@ 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 }}