fixes #13, bumped version to 3
Some checks failed
/ Lint Check Shellscripts (push) Failing after 3s
Some checks failed
/ Lint Check Shellscripts (push) Failing after 3s
This commit is contained in:
71
penv
71
penv
@@ -1,40 +1,40 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# PEnv, dead simple python venv manager. Handles creating the env and installing the jupyter spec.
|
# 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
|
# MIT Licensed, by The Grammer Society
|
||||||
|
|
||||||
# Issues:
|
# Issues:
|
||||||
# when uninstalling, remove any jupyter specs. iterate through envs in .env, call jspec remove name.
|
# when uninstalling, remove any jupyter specs. iterate through envs in .env, call jspec remove name.
|
||||||
|
|
||||||
VERSION=2
|
VERSION=3
|
||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage: penv <command> <args>"
|
echo "Usage: penv <function> <args>"
|
||||||
echo "Commands:"
|
echo "Functions:"
|
||||||
echo " - new <name> <ver=default> - Create a new environment, optional, defaults to system's default python"
|
echo "# ENV Management"
|
||||||
echo " ex: penv new tools 3.13 -> creates new environment by the name tools, using Python 3.13"
|
echo " - new <name> <ver=default> - Create a new environment, defaults to system's default python (mk)"
|
||||||
echo " ex: penv new main -> creates new env with the name main, using the default Python version on the system"
|
echo " ex: penv new tools 3.13 -> creates new env called tools, using Python 3.13"
|
||||||
echo " - del <name> - Delete existing environment"
|
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 " - setdef <name> - Use an existing environment as the default kernel"
|
||||||
echo " - activate <name> - Activates an existing environment (depricated, use pact)"
|
echo " - activate <name> - Activates an existing environment (depricated, use pact command)"
|
||||||
echo " - list - List available environments"
|
echo
|
||||||
echo " - pylist - List available PYTHON versions"
|
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 " - install - Initialize user's profile"
|
||||||
echo " - update - Update penv to latest version"
|
echo " - update - Update penv to latest version (up)"
|
||||||
echo " - uninstall - Remove ALL the environments installed using PENV"
|
echo " - uninstall - Remove ALL the environments installed with PENV"
|
||||||
echo " - help - Print this message"
|
echo " - help - Print this message"
|
||||||
echo
|
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(){
|
title(){
|
||||||
@@ -215,7 +215,7 @@ pyls(){
|
|||||||
|
|
||||||
update(){
|
update(){
|
||||||
if [[ $(realpath "$0") != "$HOME/.local/bin/penv" ]]; then
|
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
|
exit 12
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -235,6 +235,22 @@ update(){
|
|||||||
exit 0
|
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
|
if [ "$#" -lt 1 ]; then
|
||||||
title
|
title
|
||||||
@@ -276,8 +292,17 @@ case "$cmd" in
|
|||||||
update|up)
|
update|up)
|
||||||
update
|
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"
|
echo "$SCRIPT"
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user