Bash prompt, venv and ArchLabs

venv bash prompt

If you want to change the command prompt displayed by bash in such a way as to display information about the currently used virtual environment created by venv, you need to modify the PS1 variable in the .bashrc file.

In the ArchLabs distribution, the PS1 variable settings are also modified in the hidden .bash directory in the user’s directory and therefore instead of directly modifying the PS1 variable, the PROMPT_USERFMT variable should be modified, i.e.

PROMPT_USERFMT='\nvenv:(${VIRTUAL_ENV##*/})\n\u@\h:'

Then, the created variable should be exported in the .bashrc file, i.e.

export $PROMPT_USERFMT

To reload bash settings, you need to reload the .bashrc file, i.e.

source .bashrc

Leave a Reply

Your email address will not be published. Required fields are marked *