new
This commit is contained in:
parent
6486fd5a14
commit
b32da851a9
31
.rc.func.sh
31
.rc.func.sh
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user