1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-24 12:31:31 +01:00

zsh functions: add python module

This commit is contained in:
bretello 2022-04-29 11:16:39 +02:00
parent 26e313e21e
commit dff98b066f
Signed by: brethil
GPG Key ID: 876AAC6290170FE7
2 changed files with 21 additions and 12 deletions

View File

@ -263,16 +263,6 @@ make_backup() {
echo "done"
}
mkvenv(){
# 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
function find_by_mtime() {
find $@ -printf "%T+ %p\n" | sort
}

19
functions/python.zsh Normal file
View File

@ -0,0 +1,19 @@
mkvenv(){
local source_venv
if [[ $1 == "-s" ]]; then
source_venv=y
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
echo -n "Creating venv..." && python -m venv $@ .venv && echo -n " done. Enable? [Y/n]"
if [[ -z ${source_venv} ]]; then
read source_venv
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
}