配置 PowerShell Core

安装 oh-my-posh

从 scoop 安装 oh-my-posh 后再如此配置:

1
2
3
4
5
6
7
8
9
10
11
#$env:http_proxy="http://127.0.0.1:20171"; $env:https_proxy="http://127.0.0.1:20171"; $env:all_proxy="socks5://127.0.0.1:20170"

Import-Module posh-git
Import-Module PSReadLine
oh-my-posh init pwsh --config "$(scoop prefix oh-my-posh)\themes\spaceship.omp.json" | Invoke-Expression
Set-PSReadLineOption -PredictionSource History
Set-PSReadlineKeyHandler -Key Tab -Function Complete
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

如果从 brew 安装 oh-my-posh,那么配置可以变为:

1
oh-my-posh init pwsh --config "$(brew --prefix oh-my-posh)/themes/spaceship.omp.json" | Invoke-Expression