From ebc4254771082e7b556106927ec7a14169bb7761 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Mon, 5 Sep 2022 15:21:30 +0300 Subject: [PATCH] Add venv function --- bashrc.d/venv_function | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 bashrc.d/venv_function diff --git a/bashrc.d/venv_function b/bashrc.d/venv_function new file mode 100644 index 0000000..abb847d --- /dev/null +++ b/bashrc.d/venv_function @@ -0,0 +1,12 @@ +#!/bin/bash +function venv() { + if [ ${#} -gt 0 ]; then + new_venv=${1} + else + echo "Name of the Python virtual environment:" + read -r new_venv + fi + mkdir -p "${HOME}/pyenvs/${new_venv}" + python -m venv "${HOME}/pyenvs/${new_venv}" + source "${HOME}/pyenvs/${new_venv}/bin/activate" +}