Closed roxma closed 5 years ago
Current solution working for me in ZSH:
__vg_auto_deactivate() {
local activation_root
activation_root=$PWD
if [ "$VIRTUALGO" = "" ]; then
return
fi
while [ -s "$activation_root" ]; do
if [ -f "$activation_root/.virtualgo" ]; then
return
fi
# this strips the last path component from the path.
activation_root=$(echo "$activation_root" | sed 's|/[^/]*$||')
done
vg deactivate
}
chpwd_functions=(${chpwd_functions[@]} "__vg_auto_deactivate")
At the moment it's not part of the functionality. But it should be relatively easy to add. Relevant code is here:
Basically you could add if no
.virtualgo
file is found and a workspace is active, runvg deactivate
. One important thing though is probably to keep tracked if the current workspace was auto activated or not. Because if it was activated manually you wouldn't want to deactivate it when moving somewhere else.