Skip to content

Commit 9d60aba

Browse files
committed
merge ChrisHas35's postactivatehook changes
2 parents 46f4ea7 + 1cc216f commit 9d60aba

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

README

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ The ``predeactivate`` script is source before the current environment is deactiv
5858
be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old
5959
environment at the time the script runs.
6060

61+
$WORKON_HOME/postactivate
62+
=============================
63+
64+
The global ``postactivate`` script is sourced after the new environment is enabled and the new
65+
environment's postactivate is sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new
66+
environment at the time the script runs.
67+
68+
This example script adds a space between the virtual environment name and your old PS1 by making
69+
use of ``_OLD_VIRTUAL_PS1``.
70+
71+
::
72+
73+
PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1"
74+
6175
$WORKON_HOME/premkvirtualenv
6276
=============================
6377

@@ -104,6 +118,7 @@ Updates
104118

105119
1.10
106120
- Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a).
121+
- Add global postactivate hook.
107122

108123
1.9
109124
- Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug.

test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mk_test_hook premkvirtualenv
1515
mk_test_hook postmkvirtualenv
1616
mk_test_hook prermvirtualenv
1717
mk_test_hook postrmvirtualenv
18+
mk_test_hook postactivate
1819

1920
echo
2021
echo "HOOKS:"

virtualenvwrapper_bashrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ function workon () {
145145
source "$activate"
146146

147147
virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/postactivate"
148+
149+
virtualenvwrapper_source_hook "$WORKON_HOME/postactivate"
150+
148151
return 0
149152
}
150153

0 commit comments

Comments
 (0)