Compare commits

6 Commits

Author SHA1 Message Date
Phani Pavan K
43350eaa41 print reclaimed size when uninstalling env, fixed #10
Some checks failed
/ Lint Check Shellscripts (push) Failing after 13s
2026-02-06 13:02:29 +05:30
Phani Pavan K
782ef16107 change ls to find for pyls 2026-02-06 12:52:52 +05:30
Phani Pavan K
0edc8467fd implement pylist, fixes #2
Some checks failed
/ Lint Check Shellscripts (push) Failing after 32s
2026-02-06 12:50:27 +05:30
Phani Pavan K
a8ecdb60a5 fixed #1 and stderr perm issue
All checks were successful
/ Lint Check Shellscripts (push) Successful in 16s
2026-01-13 20:58:20 +05:30
Phani Pavan K
928e8b2d2d added small commands, lowercasing env names
All checks were successful
/ Lint Check Shellscripts (push) Successful in 13s
2026-01-13 20:47:10 +05:30
eb96776e3c Merge pull request 'jbomb-automate' (#4) from jbomb-automate into master
All checks were successful
/ Lint Check Shellscripts (push) Successful in 11s
Reviewed-on: #4
2026-01-13 15:03:35 +00:00
2 changed files with 20 additions and 8 deletions

4
jconf
View File

@@ -47,7 +47,7 @@ fi
cmd=$1 cmd=$1
case "$cmd" in case "$cmd" in
adduser) adduser|mku)
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]") USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd) exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
if [ "$exist" -eq 1 ]; then if [ "$exist" -eq 1 ]; then
@@ -71,7 +71,7 @@ case "$cmd" in
fi fi
exit 1 exit 1
;; ;;
deluser) deluser|rmu)
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]") USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd) exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
if [ "$exist" -eq 0 ]; then if [ "$exist" -eq 0 ]; then

24
penv Normal file → Executable file
View File

@@ -12,13 +12,14 @@ usage() {
echo "" echo ""
echo "Usage: penv <command> <args>" echo "Usage: penv <command> <args>"
echo "Commands:" echo "Commands:"
echo " - new <name> <opt:version> - Create a new environment, optional, defaults to system's default python" 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 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 " 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 " - del <name> - Delete existing environment"
# 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)"
echo " - list - List available environments" echo " - list - List available environments"
echo " - pylist - List available PYTHON versions"
echo " - install - Initialize user's profile" echo " - install - Initialize user's profile"
echo " - uninstall - Remove ALL the environments installed using PENV" echo " - uninstall - Remove ALL the environments installed using PENV"
echo " - help - Print this message" echo " - help - Print this message"
@@ -28,6 +29,7 @@ usage() {
echo " - del -> rm" echo " - del -> rm"
# echo " - setdef -> sd" # echo " - setdef -> sd"
echo " - activate -> ac, act" echo " - activate -> ac, act"
echo " - pylist -> pyls"
echo " - list -> ls" echo " - list -> ls"
} }
@@ -62,8 +64,8 @@ create(){
mkdir -p "$HOME"/.envs mkdir -p "$HOME"/.envs
/usr/bin/python"$vers" -m venv "$HOME"/.envs/"$name" /usr/bin/python"$vers" -m venv "$HOME"/.envs/"$name"
source "$HOME"/.envs/"$name"/bin/activate source "$HOME"/.envs/"$name"/bin/activate
python -m pip install ipykernel ipywidgets > /dev/stderr python -m pip install ipykernel ipywidgets
python -m ipykernel install --user --name "$name" > /dev/stderr python -m ipykernel install --user --name "$name"
echo echo
echo "Created \"$name\". It should be available as a Jupyter Kernel." echo "Created \"$name\". It should be available as a Jupyter Kernel."
echo "Use \"pact $name\" to activate in command line." echo "Use \"pact $name\" to activate in command line."
@@ -84,12 +86,14 @@ delete(){
read -r -n 1 -p "Remove environment $name (y/N)? " choise read -r -n 1 -p "Remove environment $name (y/N)? " choise
case $choise in case $choise in
[yY]) [yY])
size=$(du "$HOME"/.envs/"$name" -sh | cut -f1)
source "$HOME"/.envs/"$name"/bin/activate source "$HOME"/.envs/"$name"/bin/activate
echo echo
echo Spec $(jupyter-kernelspec remove -f -y "$name") echo Spec $(jupyter-kernelspec remove -f -y "$name")
deactivate deactivate
rm -r "$HOME/.envs/$name" rm -r "$HOME/.envs/$name"
echo "Data Removed $HOME/.envs/$name" echo "Data Removed $HOME/.envs/$name"
echo "Reclaimed $size"
;; ;;
[nN]) [nN])
echo "" echo ""
@@ -130,6 +134,7 @@ install() {
echo PENV already installed echo PENV already installed
exit 10 exit 10
fi fi
mkdir -p "$HOME/.local/bin"
cp $(realpath "$0") "$HOME"/.local/bin/ cp $(realpath "$0") "$HOME"/.local/bin/
mkdir -p "$HOME"/.envs/ mkdir -p "$HOME"/.envs/
echo " echo "
@@ -176,6 +181,10 @@ uninstall() {
echo "Uninstalled PENV" echo "Uninstalled PENV"
} }
pyls(){
find /usr/local/bin /usr/bin -name python3.* 2> /dev/null | tr " " "\n" | grep "3.*" --color=always
}
if [ "$#" -lt 1 ]; then if [ "$#" -lt 1 ]; then
title title
usage usage
@@ -186,20 +195,23 @@ cmd=$1
case "$cmd" in case "$cmd" in
new|mk) new|mk)
create "$2" "$3" create "$(echo "$2" | tr "[:upper:]" "[:lower:]")" "$3"
;; ;;
del|rm) del|rm)
delete "$2" delete "$(echo "$2" | tr "[:upper:]" "[:lower:]")"
;; ;;
# setdef|sd) # setdef|sd)
# setdef $2 # setdef $2
# ;; # ;;
act|ac) act|ac)
activate "$2" activate "$(echo "$2" | tr "[:upper:]" "[:lower:]")"
;; ;;
list|ls) list|ls)
list list
;; ;;
pylist|pyls)
pyls
;;
help) help)
title title
usage usage