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:
parent
26e313e21e
commit
dff98b066f
|
@ -263,16 +263,6 @@ make_backup() {
|
||||||
echo "done"
|
echo "done"
|
||||||
}
|
}
|
||||||
|
|
||||||
mkvenv(){
|
function find_by_mtime() {
|
||||||
# any arguments are passed on to the `venv` module as flags/arguments
|
find $@ -printf "%T+ %p\n" | sort
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
19
functions/python.zsh
Normal file
19
functions/python.zsh
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user