Skip to content

Commit 1cc216f

Browse files
author
ChrisHas35
committed
add global postactivate hook. related to #3
1 parent 3f3aee7 commit 1cc216f

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

@@ -100,6 +114,7 @@ Updates
100114

101115
1.10
102116
- Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a).
117+
- Add global postactivate hook.
103118

104119
1.9
105120
- 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)