pythonpowershellvirtualenvpowerlineoh-my-posh

How to display current virtual environtment in python in oh-my-posh?


First, I'm using hotstick.minimal theme in oh my posh. And it looks like this. enter image description here

As you can see, a current venv doesn't look good. And I made some changes in JSON file. Then it looks like this.

enter image description here

I don't want to display the name of venv on the left. How can I do that?

This is my JSON file:

{
  "$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"
          }
        }
      ]
    }
  ]
}

NOTE: Some symbols may not appear due to the font.


Solution

  • You have to include the following in your $PROFILE (profile.ps1):

    $env:VIRTUAL_ENV_DISABLE_PROMPT = 1
    

    Two notes:

    1. Deactivate the venv first
    2. Close and re-open the terminal for it to work.

    See a fuller discussion here: https://github.com/JanDeDobbeleer/oh-my-posh/discussions/390