From 6ded275dd3fec6ce68ed29e052cd054d4f1ac0da Mon Sep 17 00:00:00 2001 From: thek4n Date: Fri, 27 Sep 2024 10:05:38 +0300 Subject: [PATCH] feat bash functions ve,va --- home/user/.config/bash/functions | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/home/user/.config/bash/functions b/home/user/.config/bash/functions index 23816b5..fe9b505 100644 --- a/home/user/.config/bash/functions +++ b/home/user/.config/bash/functions @@ -40,7 +40,16 @@ ve() { } va() { - if [ -f "./venv/bin/activate" ]; then + if [[ -v 1 ]]; then + if [[ -f "${1}/bin/activate" ]]; then + source "${1}/bin/activate" + return 0 + fi + echo "va: error: virtual environment ${1} not found, use python3 -m virtualenv venv" >&2 + return 1 + fi + + if [[ -f "./venv/bin/activate" ]]; then source "./venv/bin/activate" return 0 fi @@ -49,7 +58,7 @@ va() { activate_venv="$(find -P . -maxdepth 3 -type f -wholename '*/bin/activate' | sort | head -n 1)" readonly activate_venv - if [ -n "$activate_venv" ]; then + if [[ -f "$activate_venv" ]]; then source "$activate_venv" return 0 else