1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-14 15:51:30 +01:00
dotfiles/functions/python.zsh

Failed to ignore revisions in .git-blame-ignore-revs.

25 lines
855 B
Bash
Raw Normal View History

2022-04-29 11:16:39 +02:00
mkvenv(){
local source_venv
if [[ $1 == "-s" ]]; then
source_venv=y
2022-05-03 10:16:05 +02:00
shift
2022-04-29 11:16:39 +02:00
fi
# 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
2022-05-03 10:16:05 +02:00
echo -n "Creating venv..." && python -m virtualenv $@ .venv || echo -e "Failed to create virtualenv. Is virtualenv installed? Try:\n $ pip install virtualenv"
2022-04-29 11:16:39 +02:00
if [[ -z ${source_venv} ]]; then
2022-05-03 10:16:05 +02:00
echo -n " done. Enable? [Y/n]"
2022-04-29 11:16:39 +02:00
read source_venv
2022-05-03 10:16:05 +02:00
else
echo ""
2022-04-29 11:16:39 +02:00
fi
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
}