Since the deactivate
function created by sourcing ~/bin/activate
cannot be discovered by the usual means of looking for such a command in ~/bin
, you may wish to create one that just executes the function deactivate
.
The problem is that a script named deactivate
containing a single command deactivate
will cause an endless loop if accidentally executed while not in the venv. A common mistake.
This can be avoided by only executing deactivate
if the function exists (i.e. has been created by sourcing activate
).
#!/bin/bash
declare -Ff deactivate && deactivate