This guide will help you configure PowerShell inspired by this blog post.
winget install ajeetdsouza.zoxide
winget install JanDeDobbeleer.OhMyPosh -s winget
oh-my-posh font install
code $PROFILE
oh-my-posh init pwsh --config ""$env:POSH_THEMES_PATH\kushal.omp.json" | Invoke-Expression
winget install --id=antonmedv.walk -e
winget install tldr
# Initialize Oh My Posh with the theme which we chosen
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\kushal.omp.json" | Invoke-Expression
# Set some useful Alias to shorten typing and save some key stroke
Set-Alias ll ls
Set-Alias grep findstr
# Set Some Option for PSReadLine to show the history of our typed commands
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
# enable zoxide
Invoke-Expression (& { (zoxide init powershell | Out-String) })
# replace 'Ctrl+t' and 'Ctrl+r' with your preferred bindings:
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'
# ----------------------------------------Functions ----------------------------------------------
# move in selected directory using walk
function lk() {clear | z $(walk --icons $args)}
# list json files in a folder
function Get-JsonFileList {
param(
[Parameter(Mandatory=$false)]
[string]$Path = "."
)
Get-ChildItem -Path $Path -Filter "*.json" | ForEach-Object {
$_.BaseName >> json_file_list.txt
}
}
# Utility Command that tells you where the absolute path of commandlets are
function which ($command) {
Get-Command -Name $command -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}