Created
December 6, 2017 18:31
-
-
Save kstrauser/88f958b73b0725d2a63f854dc19a94fd to your computer and use it in GitHub Desktop.
Cheap hack to emulate virtualenvwrapper's workon script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function workon () { | |
# Find the configured virtualenvwrapper home, or use Kirk's | |
# clearly excellent choice. | |
if [[ -z $PROJECT_HOME ]]; then | |
envs=$PROJECT_HOME | |
else | |
envs=~/Envs | |
fi | |
# Override the paths for specific environments | |
case $1 in | |
data_builders) | |
cd ~/Envs/data-pipelines/data_builders | |
;; | |
*) | |
cd ~/Envs/$1 | |
;; | |
esac | |
# Open a pipenv shell if possible | |
if [[ -e Pipfile ]]; then | |
pipenv shell | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've switched from using virtualenvwrapper to pipenv as it better fits my workflow. I really missed that lovely workon command, though. This is my attempt at more or less emulating its behavior:
Notes
I use Zsh, but this also works in Bash.
I create all my virtualenvs in
~/Envs
. Set$PROJECT_HOME
to your own preferred path (which you've probably already done if you'd previously used virtualenvwrapper).