脚本的执行: 在Windows系统中想要执行shell脚本,只需要安装git,安装git后,直接双击.sh脚本文件,会弹出git命令行窗口,执行命令。
创建以.sh结尾的shell脚本文件,内容如下:
#! /bin/bash
cd C:/Users/yanxu/Desktop/Typora/typora
echo "----------本地库状态----------"
git status
echo "----------本地库状态----------"
while :
do
read -r -p "是否继续提交? [Y/N] " input
case $input in
[yY][eE][sS]|[yY])
echo "----------继续提交----------"
createAt=$(date "+%Y-%m-%d %H:%M:%S")
git pull GiteeTypora master
git add .
git commit -m "${createAt}"
git push GiteeTypora master
echo "----------提交成功----------"
;;
[nN][oO]|[nN])
echo "----------中断提交----------"
sleep 1
exit 1
;;
*)
echo "输入错误,请重新输入"
continue
;;
esac
done