1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-22 03:21:30 +01:00

zsh: improve mkvenv function

This commit is contained in:
bretello 2022-03-30 15:53:03 +02:00
parent bef37c3601
commit 21d9660e64
Signed by: brethil
GPG Key ID: 876AAC6290170FE7

View File

@ -354,12 +354,15 @@ make_backup() {
}
mkvenv(){
python -m venv .venv && echo "created venv: .venv"
read -q source_venv
if [[ $source_venv == "y" ]]; then
source .venv/bin/activate && echo "sourced venv"
# any arguments are passed on to the `venv` module as flags/arguments
if [[ -e .venv ]]; then
echo "$(color $RED Error:) $(color $BOLD .venv) already exists." >&2
return 1
fi
echo -n "Creating venv..." && python -m venv $@ .venv && echo -n " done. Enable? [Y/n]"
read source_venv
if [[ $source_venv != "n" ]]; then
source .venv/bin/activate && echo -e "$(color $BOLD Enabled!) 🐍 $(color $BOLD$PURPLE $(python --version | cut -d " " -f2 )) ($(color $BOLD$GREEN $(pip --version | cut -d " " -f -2)))"
fi
}