feat: 增加switchgo
This commit is contained in:
parent
6caccc94b0
commit
b9c4f64bf0
33
.rc.func.sh
33
.rc.func.sh
@ -81,7 +81,7 @@ function switchpy() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
local python_versions=($(ls -d "$pythonlib_dir"/*/ | xargs -n 1 basename))
|
||||
python_versions=($(ls -d "$pythonlib_dir"/*/ | xargs -n 1 basename))
|
||||
|
||||
if [ ${#python_versions[@]} -eq 0 ]; then
|
||||
echo "没有找到Python版本"
|
||||
@ -103,6 +103,37 @@ function switchpy() {
|
||||
done
|
||||
}
|
||||
|
||||
function switchgo() {
|
||||
local golib_dir="$HOME/.local/share/golib"
|
||||
local go_link="$HOME/.local/share/godev"
|
||||
|
||||
if [ ! -d "$golib_dir" ]; then
|
||||
echo "Go库文件夹不存在: $golib_dir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
go_versions=($(ls -d "$golib_dir"/*/ | xargs -n 1 basename))
|
||||
|
||||
if [ ${#go_versions[@]} -eq 0 ]; then
|
||||
echo "没有找到Go版本"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "请选择一个Go版本:"
|
||||
select version in "${go_versions[@]}"; do
|
||||
if [ -n "$version" ]; then
|
||||
if [ -e "$go_link" ]; then
|
||||
rm "$go_link"
|
||||
fi
|
||||
ln -s "$golib_dir/$version" "$go_link"
|
||||
echo "Go已切换到版本: $version"
|
||||
break
|
||||
else
|
||||
echo "无效的选择"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function gitarchive() {
|
||||
first=`git log -1 --pretty=oneline | cut -d ' ' -f 1 | tail -n 1`
|
||||
second=`git log -2 --pretty=oneline | cut -d ' ' -f 1 | tail -n 1`
|
||||
|
Loading…
Reference in New Issue
Block a user