From 1c36ae8cac9e0d115ec9f671c8fc7dcfd57632c9 Mon Sep 17 00:00:00 2001 From: druckdev Date: Tue, 27 Jul 2021 03:54:10 +0200 Subject: [PATCH] zsh:funcs: Add `create_venv` --- .config/zsh/zshrc.d/40-functions.zsh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index 92631e0..21decbd 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -450,3 +450,13 @@ unbkp() { fi done } + +# Create a virtual environment for python including a .envrc that loads the venv +create_venv() { + [[ ! -e venv ]] || return 0 + python -m venv venv + if (( $+commands[direnv] )); then + ln -s ~/.local/share/direnv/templates/python-venv.envrc .envrc + direnv allow + fi +}