[新增] bash选装模块, 优化部分代码, 优化zshrc配置文件预设
This commit is contained in:
parent
0c6a7c70cc
commit
92c378b4c5
61
start.sh
61
start.sh
@ -1,10 +1,10 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# https://gitea.whlug.cn/xunmi/getLinux/src/start.sh
|
||||
|
||||
PACK_LIST=("wget" "git" "zsh")
|
||||
# 脚本根地址
|
||||
ROOT_URL="https://gitea.whlug.cn/xunmi/getLinux/"
|
||||
ROOT_TMP=/tmp/xunmi
|
||||
# 插件和依赖安装的路径
|
||||
ROOT_INSTALL=/opt/xunmi
|
||||
|
||||
###############################################################################
|
||||
@ -54,14 +54,25 @@ ColorReset() {
|
||||
# 函数 #
|
||||
###############################################################################
|
||||
|
||||
# 选择判断器
|
||||
Select_Continue() {
|
||||
Show 0 "$1((是/否 Yes/No))"
|
||||
read r
|
||||
if echo "$r" | grep -Eq "^[是Yy][Ee]?[Ss]?$";then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# 更新包管理器
|
||||
Update_Package_Resource() {
|
||||
Show 2 "更新包管理器..."
|
||||
GreyStart
|
||||
GreyStart
|
||||
if [ -x "$(command -v apt)" ]; then
|
||||
${sudo_cmd} apt update
|
||||
sudo apt-get update -qq
|
||||
elif [ -x "$(command -v yum)" ]; then
|
||||
${sudo_cmd} yum update
|
||||
sudo yum update
|
||||
fi
|
||||
ColorReset
|
||||
Show 0 "包管理器更新完毕"
|
||||
@ -69,10 +80,10 @@ Update_Package_Resource() {
|
||||
|
||||
# 安装Zsh
|
||||
Install_Zsh() {
|
||||
Update_Package_Resource
|
||||
for ((i = 0; i < ${#PACK_LIST[@]}; i++)); do
|
||||
pack=${PACK_LIST[i]}
|
||||
Show 2 "安装必要的依赖项: ${aCOLOUR[4]} $pack $COLOUR_RESET"
|
||||
Update_Package_Resource
|
||||
GreyStart
|
||||
if [ -x "$(command -v apt)" ]; then
|
||||
sudo apt -y install $pack
|
||||
@ -90,28 +101,40 @@ Install_Zsh() {
|
||||
Show 0 "依赖安装完成"
|
||||
}
|
||||
|
||||
# 下载配置
|
||||
Download_Config() {
|
||||
# 创建下载文件的临时目录
|
||||
GreyStart
|
||||
sudo rm -rf -v ${TMP_ROOT}
|
||||
mkdir -p -v ${TMP_ROOT} || Show 1 "无法创建临时目录"
|
||||
tmp_dir=$(mktemp -d -p -v ${TMP_ROOT} || Show 1 "无法创建临时目录")
|
||||
Show 0 "创建临时目录: ${tmp_dir}"
|
||||
Show 0 "正在进行插件下载与配置"
|
||||
|
||||
# 下载配置
|
||||
config_url=${ROOT_URL}/src/配置/zshrc
|
||||
wget -t 3 -q --show-progress -c "${config_url}" || Show 1 "无法下载配置"
|
||||
# 下载zsh扩展
|
||||
ohmyzsh_dir=${ROOT_INSTALL}/oh-my-zsh
|
||||
git clone https://gitcode.com/mirrors/ohmyzsh/ohmyzsh.git ${ohmyzsh_dir}
|
||||
cd -v ${ohmyzsh_dir}/custom/plugins/
|
||||
git clone https://gitcode.com/mirrors/zsh-users/zsh-autosuggestions.git
|
||||
git clone https://gitcode.com/mirrors/zsh-users/zsh-syntax-highlighting.git
|
||||
sudo cp -v ${tmp_dir}/zshrc /etc/skel/.zshrc
|
||||
sudo cp -v /etc/skel/.zshrc $HOME
|
||||
sudo git clone https://gitcode.com/mirrors/ohmyzsh/ohmyzsh.git ${ohmyzsh_dir}
|
||||
cd ${ohmyzsh_dir}/custom/plugins/
|
||||
sudo git clone https://gitcode.com/mirrors/zsh-users/zsh-autosuggestions.git
|
||||
sudo git clone https://gitcode.com/mirrors/zsh-users/zsh-syntax-highlighting.git
|
||||
# 下载预设配置
|
||||
config_url=${ROOT_URL}/raw/配置/zshrc
|
||||
sudo wget -t 3 -q --show-progress -c "${config_url}" || Show 1 "无法下载预设配置(${config_url})"
|
||||
sed -i "s/export ZSH=\/etc\/oh-my-zsh/export ZSH=$ohmyzsh_dir/" zshrc
|
||||
sudo mv zshrc /etc/skel/.zshrc
|
||||
cp -v /etc/skel/.zshrc $HOME
|
||||
ColorReset
|
||||
Show 2 "寻觅基础环境安装完成"
|
||||
}
|
||||
|
||||
# 选配
|
||||
Select_Config(){
|
||||
if Select_Continue "启动zsh"; then
|
||||
zsh
|
||||
Show 2 "zsh启动完成"
|
||||
fi
|
||||
if Select_Continue "将Zsh设置为默认命令行"; then
|
||||
sudo chsh -s /usr/bin/zsh
|
||||
Show 2 "已将zsh设置为默认命令行"
|
||||
fi
|
||||
}
|
||||
|
||||
Install_Zsh
|
||||
Download_Config
|
||||
Select_Config
|
||||
|
Loading…
x
Reference in New Issue
Block a user