Make mkv & vrun use PYTHON_VENV_NAME too

This commit is contained in:
Robert Crews 2024-03-02 18:28:02 -08:00
parent 12163f32e9
commit 81f16ed03d
2 changed files with 9 additions and 6 deletions

View file

@ -26,9 +26,11 @@ The plugin provides three utilities to manage Python 3.3+
[venv](https://docs.python.org/3/library/venv.html) virtual
environments:
- `mkv [name]`: make a new virtual environment called `name` (default: `venv`) in current directory.
- `mkv [name]`: Make a new virtual environment called *name* (else
`$PYTHON_VENV_NAME`, else "venv") in the current directory.
- `vrun [name]`: activate virtual environment called `name` (default: `venv`) in current directory.
- `vrun [name]`: Activate the virtual environment called *name* (else
`$PYTHON_VENV_NAME`, else "venv") in the current directory.
- `auto_vrun`: Automatically activate the venv virtual environment when
cding into a directory containing `venv/bin/activate`, and

View file

@ -53,9 +53,9 @@ alias pyserver="python3 -m http.server"
## venv utilities
# Activate a the python virtual environment specified.
# If none specified, use 'venv'.
# If none specified, use $PYTHON_VENV_NAME, else 'venv'.
function vrun() {
local name="${1:-venv}"
local name="${1:-${PYTHON_VENV_NAME:-venv}}"
local venvpath="${name:P}"
if [[ ! -d "$venvpath" ]]; then
@ -72,9 +72,10 @@ function vrun() {
echo "Activated virtual environment ${name}"
}
# Create a new virtual environment, with default name 'venv'.
# Create a new virtual environment using the specified name.
# If none specfied, use $PYTHON_VENV_NAME, else 'venv'.
function mkv() {
local name="${1:-venv}"
local name="${1:-${PYTHON_VENV_NAME:-venv}}"
local venvpath="${name:P}"
python3 -m venv "${name}" || return