powershell配置(5) - ohmyposh3
2021-04-01 本文已影响0人
洗洗睡吧i
1.安装
以scoop安装oh-my-posh3。
scoop install oh-my-posh3
2. 配置文件
新建、修改配置文件,运行:
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
code $PROFILE
加入以下内容:
chcp 65001
Set-PSReadLineOption -PredictionSource History # 默认是 None
oh-my-posh init pwsh --config ~\scoop\persist\oh-my-posh\themes\yo.omp.json | Invoke-Expression
ref: (https://ohmyposh.dev/docs/installation)[https://ohmyposh.dev/docs/installation]
3. 自定义ys主题
- 打开主题文件,路径:
~\scoop\persist\oh-my-posh\themes\yo.omp.json
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "red",
"properties": {
"template": "{{ if .Root }}% {{ else }}<blue># </>{{end}}"
},
"style": "plain",
"type": "text"
},
{
"foreground": "cyan",
"properties": {
"template": "{{ .UserName }}<white> @ </><green>{{ .HostName }}</>"
},
"style": "plain",
"type": "session"
},
{
"foreground": "lightYellow",
"properties": {
"style": "short",
"template": "<white> in </>{{ .Path }} "
},
"style": "plain",
"type": "path"
},
{
"foreground": "cyan",
"properties": {
"fetch_status": true,
"template": []
},
"style": "plain",
"type": "git"
},
{
"foreground": "white",
"properties": {
"template": "[{{ .CurrentDate | date .Format }}]",
"time_format": "15:04:05"
},
"style": "plain",
"type": "time"
},
{
"foreground": "red",
"properties": {
"template": " C: {{ .Code }}"
},
"style": "plain",
"type": "exit"
}
],
"type": "prompt"
},
{
"type": "newline"
},
{
"alignment": "left",
"segments": [
{
"foreground": "red",
"properties": {
"template": "$"
},
"style": "plain",
"type": "text"
}
],
"type": "prompt"
}
],
"console_title": true,
"console_title_style": "template",
"console_title_template": "{{.User}} :: {{.Folder}} :: {{.Shell}}",
"final_space": true,
"version": 1
}
done!