zsh: improve mkvenv function

pull/6/head
bretello 2022-03-30 15:53:03 +02:00
parent bef37c3601
commit 21d9660e64
Signed by: brethil
GPG Key ID: 876AAC6290170FE7
1 changed files with 9 additions and 6 deletions

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
}