Skip to content

The VIRTUAL_ENV_PROMPT variable is ignored when using Python's venv module #640

@jwm-evans

Description

@jwm-evans

If I create a new Python virtualenv using python3 -m env --prompt test .venv and activate it by source .venv/bin/activate, the prompt shows ( .venv ) instead of ( test ).

This can be resolved by changing function _omb_prompt_get_virtualenv to:

 function _omb_prompt_get_virtualenv {
   virtualenv=
   [[ ${VIRTUAL_ENV-} ]] || return 1
   if [[ -n $VIRTUAL_ENV_PROMPT ]]; then
     _omb_prompt_format virtualenv "$VIRTUAL_ENV_PROMPT" OMB_PROMPT_VIRTUALENV:VIRTUALENV_THEME_PROMPT
   else
     _omb_prompt_format virtualenv "$(basename "$VIRTUAL_ENV")" OMB_PROMPT_VIRTUALENV:VIRTUALENV_THEME_PROMPT
   fi
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions