This commit is contained in:
dmahacker 2024-03-15 16:59:58 +08:00
parent 6486fd5a14
commit b32da851a9
2 changed files with 32 additions and 0 deletions

View File

@ -67,3 +67,34 @@ function goenv() {
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOPRIVATE=golang.wrdtech.com
}
function switchpy() {
local pythonlib_dir="$HOME/.local/share/pythonlib"
local python_link="$HOME/.local/share/python"
if [ ! -d "$pythonlib_dir" ]; then
echo "Python库文件夹不存在: $pythonlib_dir"
return 1
fi
local python_versions=($(ls -d "$pythonlib_dir"/*/ | xargs -n 1 basename))
if [ ${#python_versions[@]} -eq 0 ]; then
echo "没有找到Python版本"
return 1
fi
echo "请选择一个Python版本:"
select version in "${python_versions[@]}"; do
if [ -n "$version" ]; then
if [ -e "$python_link" ]; then
rm "$python_link"
fi
ln -s "$pythonlib_dir/$version" "$python_link"
echo "Python已切换到版本: $version"
break
else
echo "无效的选择"
fi
done
}

1
.zshrc
View File

@ -13,3 +13,4 @@ plugins=(
source ~/.keychain.sh
source ~/.rc.sh
source $ZSH/oh-my-zsh.sh
source /usr/share/nvm/init-nvm.sh