Created
January 17, 2021 22:07
-
-
Save rogfrich/a3941f49c3a6aab6a76d3c9279da7166 to your computer and use it in GitHub Desktop.
Sample zsh / Bash script with aliases and a function to manage Python venvs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script is an example of how to simplify the creation, activation and deactivation of Python virtual environments. | |
alias we="which python" | |
alias ae='deactivate &> /dev/null; source ./venv/bin/activate' | |
alias de="deactivate" | |
# Function to create an environment and optionally set a custom prompt | |
ce() { | |
if [ -z "$1" ] # If the first parameter is an empty string (i.e no parameter supplied) | |
then | |
python3 -m venv venv | |
else | |
python3 -m venv venv --prompt $1 | |
fi | |
ae | |
echo "Created and activated:" && we | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment