Skip to content

Commit b9a9d2f

Browse files
committed
add virtualenvwrapper hook scripts
0 parents  commit b9a9d2f

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

postmkvirtualenv

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/zsh
2+
# This hook is sourced after a new virtualenv is activated.
3+
4+
echo triggered postmkvirtualenv script
5+
6+
create_venv_symlink(){
7+
echo $VIRTUAL_ENV
8+
if [ -d $VIRTUAL_ENV ];
9+
then
10+
echo creating symlink to virtualenvwrapper environemnt
11+
12+
ln -s $VIRTUAL_ENV venv
13+
14+
echo 'ln -s' $VIRTUAL_ENV venv
15+
fi
16+
}
17+
18+
create_venv_symlink

postrmvirtualenv

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/zsh
2+
# This hook is run after a virtualenv is deleted.
3+
# argument: full path to environment directory
4+
5+
project_name=$(basename $1)
6+
venv_symlink=$HOME/server/$project_name/venv
7+
8+
echo 'searching for symlink:' $venv_symlink
9+
if [ -L "$venv_symlink" ];
10+
then
11+
echo 'found a symlink to the deleted environment'
12+
echo 'removing it...'
13+
rm -rf $venv_symlink
14+
echo 'rm -rf' $venv_symlink
15+
else
16+
echo 'no symlink traces found'
17+
fi

0 commit comments

Comments
 (0)