Skip to content

Commit f32241d

Browse files
committed
Support "workon ."
If the literal string "." is passed to workon, use the current working directory to derive the virtualenv name. Activation happens normally, which may involve changing directories out of the current directory (possibly even changing back, depending on what postactivate hooks do). Change-Id: Ia2de0bf05a52a95e4979c58bd868ae309f23540d
1 parent b380f2f commit f32241d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/test_workon.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,11 @@ test_no_workon_home () {
116116
WORKON_HOME="$old_home"
117117
}
118118

119+
test_workon_dot () {
120+
cd $WORKON_HOME/env1
121+
workon .
122+
assertTrue virtualenvwrapper_verify_active_environment
123+
assertSame "env1" $(basename "$VIRTUAL_ENV")
124+
}
125+
119126
. "$test_dir/shunit2"

virtualenvwrapper.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,9 @@ function workon {
722722
then
723723
lsvirtualenv -b
724724
return 1
725+
elif [ "$env_name" = "." ]
726+
then
727+
env_name=$(basename $(pwd))
725728
fi
726729

727730
virtualenvwrapper_verify_workon_home || return 1

0 commit comments

Comments
 (0)