title: Powershell配置
tags: [shell, 配置]
date: 2022-12-09 11:56:51
date modified: 2024-01-27 21:37:10
sticker: ""Powershell配置
安装方式又很多种,我这里用的官方推荐的winget安装方式[1]:
winget search Microsoft.PowerShell
winget install --id Microsoft.Powershell --source winget
windows11的话直接用 Winget 执行安装命令[2]就可以了,还是相当方便的
winget install JanDeDobbeleer.OhMyPosh -s winget
使用 notepad $profile 打开配置文件,在开头部分增加以下代码:
#配置oh-my-posh自动加载,并且设置主题为 catppuccin_frappe
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\catppuccin_frappe.omp.json" | Invoke-Expression
# 下面是配置自动完成和自动提示
# Shows navigable menu of all options when hitting Tab
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Autocompletion for arrow keys
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
# auto suggestions
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History