powerlevel10k icon indicating copy to clipboard operation
powerlevel10k copied to clipboard

Wrong Python environment names

Open vict0rsch opened this issue 2 years ago • 6 comments

Hi,

when I activate a new environment, for some reason its name "sticks" to the Python segment:

  1. No Python seg
  2. Activate env
  3. Right name is displayed
  4. Activate other env
  5. Right name is displayed
  6. Deactivate
  7. No Python segment (as expected)
  8. Activate first environment
  9. Second name is displayed, and for any subsequent env

SCR-20240110-ohmz

  typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37
  # Don't show Python version next to the virtual environment name.
  typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=true
  # If set to "false", won't show virtualenv if pyenv is already shown.
  # If set to "if-different", won't show virtualenv if it's the same as pyenv.
  typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
  # Separate environment name from Python version only with a space.
  typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=

When setting POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION to true, it displays the correct Python version but still the wrong name.

vict0rsch avatar Jan 10 '24 21:01 vict0rsch

What is the output of the following command when the wrong name is displayed?

typeset -p VIRTUAL_ENV

romkatv avatar Jan 10 '24 21:01 romkatv

SCR-20240110-okfy Right env, wrong display

vict0rsch avatar Jan 10 '24 21:01 vict0rsch

Which segment is displaying "gfn-113" on the right? You can figure this out by commenting out all segments within POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS in ~/.p10k.zsh except one.

romkatv avatar Jan 10 '24 21:01 romkatv

With virtualenv only in POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS:

SCR-20240110-omru

vict0rsch avatar Jan 10 '24 21:01 vict0rsch

(and still:

❯ typeset -p VIRTUAL_ENV
export VIRTUAL_ENV=/Users/victor/.virtualenvs/gflownet

)

vict0rsch avatar Jan 10 '24 21:01 vict0rsch

(venv activate $NAME is a function to execute source ~/.virtualenvs/$NAME/bin/activate)

vict0rsch avatar Jan 10 '24 21:01 vict0rsch

What's the output of this command?

typeset -p VIRTUAL_ENV_PROMPT

romkatv avatar Jan 11 '24 04:01 romkatv

Looks like we're getting somewhere indeed

SCR-20240111-kqoh

vict0rsch avatar Jan 11 '24 16:01 vict0rsch

There you go. Powerlevel10k respects this override. If you don't want it, disable it in the virtualenv. I don't know how but I recall there is a way.

romkatv avatar Jan 11 '24 16:01 romkatv

Ok thanks!

Putting export VIRTUAL_ENV_DISABLE_PROMPT=1 in my .zshrc fixes the issue.

vict0rsch avatar Jan 11 '24 16:01 vict0rsch

👍

romkatv avatar Jan 11 '24 16:01 romkatv