mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
Use in Virtualenvwrapper plugin
This commit is contained in:
parent
4c91a70947
commit
bce83c941e
1 changed files with 5 additions and 4 deletions
|
|
@ -7,10 +7,10 @@ if [[ -f "$wrapsource" ]]; then
|
||||||
# Automatically activate Git projects' virtual environments based on the
|
# Automatically activate Git projects' virtual environments based on the
|
||||||
# directory name of the project. Virtual environment name can be overridden
|
# directory name of the project. Virtual environment name can be overridden
|
||||||
# by placing a .venv file in the project root with a virtualenv name in it
|
# by placing a .venv file in the project root with a virtualenv name in it
|
||||||
function workon_cwd {
|
function _workon_cwd {
|
||||||
# Check that this is a Git repo
|
# Check that this is a Git repo
|
||||||
PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
|
PROJECT_ROOT=`git_get_root`
|
||||||
if (( $? == 0 )); then
|
if [[ -n "$PROJECT_ROOT" ]]; then
|
||||||
# Check for virtualenv name override
|
# Check for virtualenv name override
|
||||||
ENV_NAME=`basename "$PROJECT_ROOT"`
|
ENV_NAME=`basename "$PROJECT_ROOT"`
|
||||||
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
|
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
|
||||||
|
|
@ -28,11 +28,12 @@ if [[ -f "$wrapsource" ]]; then
|
||||||
deactivate && unset CD_VIRTUAL_ENV
|
deactivate && unset CD_VIRTUAL_ENV
|
||||||
fi
|
fi
|
||||||
unset PROJECT_ROOT
|
unset PROJECT_ROOT
|
||||||
|
unset ENV_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
# New cd function that does the virtualenv magic
|
# New cd function that does the virtualenv magic
|
||||||
function cd {
|
function cd {
|
||||||
builtin cd "$@" && workon_cwd
|
builtin cd "$@" && _workon_cwd
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue