From 3585a4c5e77d13f9f74dc7904c4775ce896e6162 Mon Sep 17 00:00:00 2001 From: Phani Pavan K Date: Tue, 10 Mar 2026 00:44:35 +0530 Subject: [PATCH] fixes #13, bumped version to 3 --- penv | 71 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/penv b/penv index 1310446..a69f774 100755 --- a/penv +++ b/penv @@ -1,40 +1,40 @@ #!/bin/bash # PEnv, dead simple python venv manager. Handles creating the env and installing the jupyter spec. -# Version 0.1 - 20th Nov, 2025 +# Initial Version - 20th Nov, 2025 # MIT Licensed, by The Grammer Society # Issues: # when uninstalling, remove any jupyter specs. iterate through envs in .env, call jspec remove name. -VERSION=2 +VERSION=3 usage() { echo "" - echo "Usage: penv " - echo "Commands:" - echo " - new - Create a new environment, optional, defaults to system's default python" - echo " ex: penv new tools 3.13 -> creates new environment by the name tools, using Python 3.13" - echo " ex: penv new main -> creates new env with the name main, using the default Python version on the system" - echo " - del - Delete existing environment" + echo "Usage: penv " + echo "Functions:" + echo "# ENV Management" + echo " - new - Create a new environment, defaults to system's default python (mk)" + echo " ex: penv new tools 3.13 -> creates new env called tools, using Python 3.13" + echo " ex: penv new prj9 -> creates new env called prj9, using the default Python" + echo " - del - Delete existing environment (rm)" # echo " - setdef - Use an existing environment as the default kernel" - echo " - activate - Activates an existing environment (depricated, use pact)" - echo " - list - List available environments" - echo " - pylist - List available PYTHON versions" + echo " - activate - Activates an existing environment (depricated, use pact command)" + echo + echo "# ENV Info" + echo " - list - List created environments (ls)" + echo " - pylist - List accessible PYTHON versions (pyls)" + echo " - printloc - Print absolute environment path (loc)" + echo " - openloc - Open environment directory in default file manager (open)" + echo + echo "# Script Management" echo " - install - Initialize user's profile" - echo " - update - Update penv to latest version" - echo " - uninstall - Remove ALL the environments installed using PENV" + echo " - update - Update penv to latest version (up)" + echo " - uninstall - Remove ALL the environments installed with PENV" echo " - help - Print this message" echo - echo "Aliases:" - echo " - new -> mk" - echo " - del -> rm" - # echo " - setdef -> sd" - echo " - activate -> ac, act" - echo " - pylist -> pyls" - echo " - list -> ls" - echo " - update -> up" + } title(){ @@ -215,7 +215,7 @@ pyls(){ update(){ if [[ $(realpath "$0") != "$HOME/.local/bin/penv" ]]; then - echo PENV not installed yet. Install it to use the update command. + echo PENV not installed yet. Install it to use the update function. exit 12 fi @@ -235,6 +235,22 @@ update(){ exit 0 } +printloc(){ + if [ ! -d "$HOME/.envs/$1" ]; then + echo "Environment \"$1\" not found" + exit 5 + fi + echo $HOME/.envs/$1 +} + +openloc() { + if [ ! -d "$HOME/.envs/$1" ]; then + echo "Environment \"$1\" not found" + exit 5 + fi + xdg-open $HOME/.envs/$1 +} + if [ "$#" -lt 1 ]; then title @@ -276,8 +292,17 @@ case "$cmd" in update|up) update ;; + printloc|loc) + printloc "$(echo "$2" | tr "[:upper:]" "[:lower:]")" + ;; + openloc|open) + openloc "$(echo "$2" | tr "[:upper:]" "[:lower:]")" + ;; + cd) + chd "$(echo "$2" | tr "[:upper:]" "[:lower:]")" + ;; *) - echo "invalid command: \"$1\"" >&2 + echo "invalid function: \"$1\"" >&2 echo "$SCRIPT" usage ;;