fixes #13, bumped version to 3
Some checks failed
/ Lint Check Shellscripts (push) Failing after 3s

This commit is contained in:
2026-03-10 00:44:35 +05:30
parent e2c518c913
commit 3585a4c5e7

71
penv
View File

@@ -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 <command> <args>"
echo "Commands:"
echo " - new <name> <ver=default> - 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 <name> - Delete existing environment"
echo "Usage: penv <function> <args>"
echo "Functions:"
echo "# ENV Management"
echo " - new <name> <ver=default> - 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 <name> - Delete existing environment (rm)"
# echo " - setdef <name> - Use an existing environment as the default kernel"
echo " - activate <name> - Activates an existing environment (depricated, use pact)"
echo " - list - List available environments"
echo " - pylist - List available PYTHON versions"
echo " - activate <name> - 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 <name> - Print absolute environment path (loc)"
echo " - openloc <name> - 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
;;