Skip to content

Commit 294cfcb

Browse files
committed
New -d option to 'add2virtualenv' which allows removal of a path previously added.
1 parent f54ea7a commit 294cfcb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

virtualenvwrapper_bashrc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,13 @@ function add2virtualenv () {
372372
return 1
373373
fi
374374

375+
remove=0
376+
if [ "$1" = "-d" ]
377+
then
378+
remove=1
379+
shift
380+
fi
381+
375382
if [ ! -x "$path_file" ]
376383
then
377384
echo "import sys; sys.__plen = len(sys.path)" >> "$path_file"
@@ -385,8 +392,14 @@ function add2virtualenv () {
385392
then
386393
echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2
387394
fi
395+
388396
contents=$(cat "$path_file")
389-
echo "$contents" | sed "1a $absolute_path" > "$path_file"
397+
if [ $remove -eq 1 ]
398+
then
399+
echo "$contents" | sed "\:^$absolute_path$: d" > "$path_file"
400+
else
401+
echo "$contents" | sed "1a $absolute_path" > "$path_file"
402+
fi
390403
done
391404
return 0
392405
}

0 commit comments

Comments
 (0)