gpt4 book ai didi

python - 如何在 oh-my-posh 中用 python 显示当前虚拟环境?

转载 作者:行者123 更新时间:2023-12-05 02:40:16 34 4
gpt4 key购买 nike

首先,我在 oh my posh 中使用 hotstick.minimal 主题。它看起来像这样。 enter image description here

如您所见,当前的 venv 看起来不太好。我对 JSON 文件做了一些更改。然后它看起来像这样。

enter image description here

我不想在左侧显示 venv 的名称。我该怎么做?

这是我的 JSON 文件:

{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"osc99": true,
"console_title": true,
"console_title_style": "template",
"console_title_template": "{{.Folder}}{{if .Root}} :: root{{end}} :: {{.Shell}}",
"blocks": [

{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "root",
"style": "plain",
"foreground": "yellow",
"properties": {
"root_icon": ""
}
},
{
"type": "path",
"style": "powerline",
"foreground": "black",
"background": "#68D6D6",
"powerline_symbol": "",
"leading_diamond": "",
"trailing_diamond": "",
"properties": {
"prefix": " \uF07C ",
"style": "folder"
}
},
{
"type": "python",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#100e23",
"background": "#906cff",
"properties": {
"prefix": " \uE235 "
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "",
"foreground": "black",
"background": "green",
"properties": {
"display_stash_count": true,
"display_upstream_icon": true,
"display_status": true,
"display_status_detail": true,
"branch_icon": "  ",
"branch_identical_icon": "≡",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone": "≢",
"local_working_icon": "",
"local_staged_icon": "",
"stash_count_icon": "",
"commit_icon": "▷ ",
"tag_icon": "▶ ",
"rebase_icon": "Ɫ ",
"cherry_pick_icon": "✓ ",
"merge_icon": "◴ ",
"no_commits_icon": "[no commits]",
"status_separator_icon": " │",
"status_colors_enabled": true,
"color_background": true,
"local_changes_color": "yellow"
}
}
]
}
]
}

注意:由于字体的原因,某些符号可能不会出现。

最佳答案

您必须在 $PROFILE (profile.ps1) 中包含以下内容:

$env:VIRTUAL_ENV_DISABLE_PROMPT = 1

两个注意事项:

  1. 首先停用 venv
  2. 关闭并重新打开终端以使其正常工作。

在此处查看更全面的讨论:https://github.com/JanDeDobbeleer/oh-my-posh/discussions/390

关于python - 如何在 oh-my-posh 中用 python 显示当前虚拟环境?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68649314/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com