Keep active virtualenv on new tab
Asked Answered
N

1

10

I use gnome-terminal with zsh. I recently had an issue with keeping the current working directory when opening a new tab (CTRL+SHIFT+T) since it used to reset itself to $HOME everytime. I solved it by adding:

. /etc/profile.d/vte.sh

to the .zshrc file.

Now, since I use virtualenv (and virtualenvwrapper) I would like to avoid having to do workon virtualenv_name each time I open a new tab.

The obvious solution is to put that command in the .zshrc, however I don't want to always enter the virtualenv. I want to do it only when I open a new tab and I am already inside a virtualenv.

Now, since a virtualenv is just a modification to PATH, PS1, and stuff like that, I guess I can do this in some way. Any ideas?

Nonprofit answered 30/8, 2015 at 16:36 Comment(0)
H
1

Use one of the auto export solutions, e.g. https://direnv.net or https://github.com/kennethreitz/autoenv. These solutions can be used to turn on a virtual env when cding into its directory.

Hejira answered 7/6, 2018 at 5:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.