Simple pipenv bash alternative, virtual-environment management helper.
Work and create python virtualenvs in a central directory, use sub-shell for activation and run arbitrary commands in envs.
Before, make sure you're using Python 3 and/or have virtualenv
installed.
On macOS, you can simply use brew: brew install rafi/tap/workon-py
Otherwise, change directory to installation location, for example ~/.local/bin
:
$ cd ~/.local/bin
$ curl -L https://github.com/rafi/workon-py/tarball/master | tar zx --strip-components=1
See shell completion for helpful shell completions.
usage: workon [arguments] <virtualenv>
arguments:
-c, --create create and activate a new virtualenv
--no-install when creating, don't install requirements
-d, --delete Delete virtualenv
-r, --run <cmd> Run a binary from virtualenv
-h, --help show this help message and exit
environment variables:
WORKON_HOME Path to create venvs, default: ${XDG_DATA_HOME}/python/envs
WORKON_VIRTUALENV Optional, set specific virtualenv path
Leave empty for interactive selection.
To create a new virtualenv, use -c
, you will be prompted which
virtualenv to use, if more than one version is found:
$ workon -c foobar
1) python3 -m venv 3) /usr/local/bin/virtualenv
1) /usr/local/bin/virtualenv-3.7 4) /usr/local/bin/virtualenv-2.7
:: Select virtualenv program to use:
You can use paths when creating a new virtualenv, e.g.:
cd myproject
workon -c .
This will create a unique virtualenv name with the crc32 of path,
i.e. myproject-8bfb376d
.
Provide the name of a virtualenv, or without arguments and fzf
/fzy
will be used to interactively select a virtual-environment.
workon foobar
To deactivate, simply type exit
or hit Ctrl+d
You can run "one-off" commands within the virtualenv's binary directory, for example list all pip installed packages:
workon -r myproject pip list
Add the completion script to your .bash_profile
or .bashrc
:
source "$HOME/.local/bin/workon-completion.bash"
None available currently, pull-requests are welcomed.
- Virtualenv's bin/activate is Doing It Wrong (article)
- autoenv - directory-based environments (shell)
- capn - specify hooks when changing directories (python)
- pew - manage multiple virtual environments (python)
- vex - run a command in the named virtualenv (python)
- pipenv - Python Development Workflow (python)
Copyright (C) 2015-2019 Rafael Bodill
Distributed under the GNU General Public License, version 2.0.