Gitin: 一键从 GitHub、Gitee 和 Moeyy 下载或克隆仓库
Gitin: 一键从 GitHub、Gitee 和 Moeyy 下载或克隆仓库
Gitin 是一个简单的 shell 函数,可以方便地从 GitHub、Gitee 和 Moeyy 下载或克隆仓库。它支持 download 和 clone 两种操作,并可以指定目标仓库的 URL。
使用方法
gitin download/clone -github url1 -gitee url2 -moeyy url3
download/clone: 指定操作类型,可以选择download或clone。-github url1: 指定 GitHub 仓库的 URL。-gitee url2: 指定 Gitee 仓库的 URL。-moeyy url3: 指定 Moeyy 仓库的 URL。
代码示例
# 定义 gitin 函数
gitin() {
# 检查参数
if [ $# -ne 7 ]; then
echo '使用方法: gitin download/clone -github url1 -gitee url2 -moeyy url3'
return 1
fi
# 解析参数
case $1 in
download|Download|dow|Dow)
if [ "${wheregit}" = gitee ]; then
wget -q --show-progress ${gitee_url}
elif [ "${wheregit}" = github ]; then
wget -q --show-progress ${github_url}
elif [ "${wheregit}" = moeyy ]; then
wget -q --show-progress ${moeyy_url}
fi
;;
clone)
if [ "${wheregit}" = gitee ]; then
git clone --depth=1 ${gitee_url}
elif [ "${wheregit}" = github ]; then
git clone --depth=1 ${github_url}
elif [ "${wheregit}" = moeyy ]; then
git clone --depth=1 ${moeyy_url}
fi
;;
esac
}
# 设置 wheregit 变量
wheregit="github"
# 从 GitHub 克隆仓库
gitin clone -github https://github.com/yoimiya-kokomi/Miao-Yunzai.git -gitee https://gitee.com/yoimiya-kokomi/Miao-Yunzai.git -moeyy https://github.moeyy.xyz/https://github.com/yoimiya-kokomi/Miao-Yunzai.git
注意
wheregit变量需要在调用gitin函数之前进行赋值,用于指定默认下载或克隆的仓库平台。- 此代码示例仅供参考,您需要根据实际情况进行修改和调整。
希望这个 shell 函数能够帮助您更方便地从不同的代码托管平台下载或克隆仓库。
原文地址: https://www.cveoy.top/t/topic/o7Dk 著作权归作者所有。请勿转载和采集!