added update function for penv, to impl for jconf
Some checks failed
/ Lint Check Shellscripts (push) Failing after 4s

This commit is contained in:
Phani Pavan K
2026-02-14 17:07:02 +05:30
parent a9f3b3ac37
commit 46f327436f
2 changed files with 32 additions and 1 deletions

31
penv
View File

@@ -5,9 +5,11 @@
# MIT Licensed, by The Grammer Society
# Issues:
# names are fully lower case when installed as jupyterhub spec. convert name to lower case when deleting an env.
# when uninstalling, remove any jupyter specs. iterate through envs in .env, call jspec remove name.
VERSION=1
usage() {
echo ""
echo "Usage: penv <command> <args>"
@@ -21,6 +23,7 @@ usage() {
echo " - list - List available environments"
echo " - pylist - List available PYTHON versions"
echo " - install - Initialize user's profile"
echo " - update - Update penv to latest version"
echo " - uninstall - Remove ALL the environments installed using PENV"
echo " - help - Print this message"
echo
@@ -31,6 +34,7 @@ usage() {
echo " - activate -> ac, act"
echo " - pylist -> pyls"
echo " - list -> ls"
echo " - update -> up"
}
title(){
@@ -163,6 +167,7 @@ install() {
" > "$HOME"/.envs/.penv.funcs
add2RC bashrc
add2RC zshrc
chmod +x "$HOME/.local/bin/penv"
echo "Initialized PENV. Restart the shell"
}
@@ -203,6 +208,27 @@ pyls(){
find /usr/local/bin /usr/bin -name "python3.*" 2> /dev/null | tr " " "\n" | grep "3.*" --color=always
}
update(){
if [[ $(realpath "$0") != "$HOME/.local/bin/penv" ]]; then
echo PENV not installed yet. Install it to use the update command.
exit 12
fi
if [ -x "$(command -v curl)" ]; then
curl "https://git.pvnweb.dedyn.io/phanipavank/jbomb/raw/branch/master/penv" -o "$HOME/.local/bin/penv"
elif [ -x "$(command -v wget)" ]; then
wget -o "$HOME/.local/bin/penv" "https://git.pvnweb.dedyn.io/phanipavank/jbomb/raw/branch/master/penv"
else
echo Curl or wget not found. Install either one to update penv.
fi
chmod +x "$HOME/.local/bin/penv"
sleep 0.5
newVer=$(grep VERSION "$HOME/.local/bin/penv" | cut -d '=' -f 2)
echo "PENV updated from $VERSION to $newVer"
exit 0
}
if [ "$#" -lt 1 ]; then
title
usage
@@ -240,6 +266,9 @@ case "$cmd" in
uninstall)
uninstall
;;
update|up)
update
;;
*)
echo "invalid command: \"$1\"" >&2
echo "$SCRIPT"