2

I am using archlinux with zsh and python

simha@gauranga ~ % echo $SHELL
/usr/bin/zsh

simha@gauranga ~ % python3 --version
Python 3.5.1

my .zshrc is

export WORKON_HOME=~/.virtualenvs
source /usr/bin/virtualenvwrapper.sh

Once i open a new terminal

I could create a new virtualenv in the following way. (simha is the home folder name and gauranga is the computer name)

simha@gauranga ~ % mkvirtualenv new2
Using base prefix '/usr'
New python executable in /home/simha/.virtualenvs/new3/bin/python3
Also creating executable in /home/simha/.virtualenvs/new3/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/simha/.virtualenvs/new3/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/simha/.virtualenvs/new3/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/simha/.virtualenvs/new3/bin/preactivate
virtualenvwrapper.user_scripts creating /home/simha/.virtualenvs/new3/bin/postactivate
virtualenvwrapper.user_scripts creating /home/simha/.virtualenvs/new3/bin/get_env_details

Now i am entering the virtualenv

simha@gauranga ~ % workon new3
simha@gauranga ~ %

if we see above there is no change in the prompt to shown which env in am in.

I have followed the http://virtualenvwrapper.readthedocs.io/en/latest/tips.html for zsh prompt still its not working

the following are the postactivate and postdeactivate files

simha@gauranga ~ % tail -f .virtualenvs/postactivate .virtualenvs/postdeactivate
==> .virtualenvs/postactivate <==
PS1="$_OLD_VIRTUAL_PS1"
_OLD_RPROMPT="$RPROMPT"
RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[green]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT"

==> .virtualenvs/postdeactivate <==
RPROMPT="$_OLD_RPROMPT"
0

If you're using the grml zsh config, which is the default configuration for ArchLinux, then you'll need to do some theme configuration in your ~/.zshrc file.

Grml's current setup uses prompt themes, which use the prompt variable PS1. PS1 is used by virtualenv to display the current active virtualenvironment. If virtualenv changes the PS1 variable, the theme code will just change it back to the value of the current theme.

Adding:

source /usr/bin/virtualenvwrapper.sh
export WORKON_HOME=~/.virtualenvs
function virtual_env_prompt () {
REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) }
}
grml_theme_add_token virtual-env -f virtual_env_prompt '%F{magenta}' '%f'
zstyle ':prompt:grml:left:setup' items rc virtual-env change-root user at host path vcs percent

To your .zshrc file should do the trick.

Source of wording and answer:
http://bewatermyfriend.org/p/2013/003/

Edits: wording and spelling

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.