[新增] bash选装模块, 优化部分代码, 优化zshrc配置文件预设
This commit is contained in:
parent
0c6a7c70cc
commit
92c378b4c5
61
start.sh
61
start.sh
@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
|
|
||||||
# https://gitea.whlug.cn/xunmi/getLinux/src/start.sh
|
# https://gitea.whlug.cn/xunmi/getLinux/src/start.sh
|
||||||
|
|
||||||
PACK_LIST=("wget" "git" "zsh")
|
PACK_LIST=("wget" "git" "zsh")
|
||||||
|
# 脚本根地址
|
||||||
ROOT_URL="https://gitea.whlug.cn/xunmi/getLinux/"
|
ROOT_URL="https://gitea.whlug.cn/xunmi/getLinux/"
|
||||||
ROOT_TMP=/tmp/xunmi
|
# 插件和依赖安装的路径
|
||||||
ROOT_INSTALL=/opt/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() {
|
Update_Package_Resource() {
|
||||||
Show 2 "更新包管理器..."
|
Show 2 "更新包管理器..."
|
||||||
GreyStart
|
GreyStart
|
||||||
if [ -x "$(command -v apt)" ]; then
|
if [ -x "$(command -v apt)" ]; then
|
||||||
${sudo_cmd} apt update
|
sudo apt-get update -qq
|
||||||
elif [ -x "$(command -v yum)" ]; then
|
elif [ -x "$(command -v yum)" ]; then
|
||||||
${sudo_cmd} yum update
|
sudo yum update
|
||||||
fi
|
fi
|
||||||
ColorReset
|
ColorReset
|
||||||
Show 0 "包管理器更新完毕"
|
Show 0 "包管理器更新完毕"
|
||||||
@ -69,10 +80,10 @@ Update_Package_Resource() {
|
|||||||
|
|
||||||
# 安装Zsh
|
# 安装Zsh
|
||||||
Install_Zsh() {
|
Install_Zsh() {
|
||||||
|
Update_Package_Resource
|
||||||
for ((i = 0; i < ${#PACK_LIST[@]}; i++)); do
|
for ((i = 0; i < ${#PACK_LIST[@]}; i++)); do
|
||||||
pack=${PACK_LIST[i]}
|
pack=${PACK_LIST[i]}
|
||||||
Show 2 "安装必要的依赖项: ${aCOLOUR[4]} $pack $COLOUR_RESET"
|
Show 2 "安装必要的依赖项: ${aCOLOUR[4]} $pack $COLOUR_RESET"
|
||||||
Update_Package_Resource
|
|
||||||
GreyStart
|
GreyStart
|
||||||
if [ -x "$(command -v apt)" ]; then
|
if [ -x "$(command -v apt)" ]; then
|
||||||
sudo apt -y install $pack
|
sudo apt -y install $pack
|
||||||
@ -90,28 +101,40 @@ Install_Zsh() {
|
|||||||
Show 0 "依赖安装完成"
|
Show 0 "依赖安装完成"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 下载配置
|
||||||
Download_Config() {
|
Download_Config() {
|
||||||
# 创建下载文件的临时目录
|
# 创建下载文件的临时目录
|
||||||
GreyStart
|
GreyStart
|
||||||
sudo rm -rf -v ${TMP_ROOT}
|
Show 0 "正在进行插件下载与配置"
|
||||||
mkdir -p -v ${TMP_ROOT} || Show 1 "无法创建临时目录"
|
|
||||||
tmp_dir=$(mktemp -d -p -v ${TMP_ROOT} || Show 1 "无法创建临时目录")
|
|
||||||
Show 0 "创建临时目录: ${tmp_dir}"
|
|
||||||
|
|
||||||
# 下载配置
|
|
||||||
config_url=${ROOT_URL}/src/配置/zshrc
|
|
||||||
wget -t 3 -q --show-progress -c "${config_url}" || Show 1 "无法下载配置"
|
|
||||||
# 下载zsh扩展
|
# 下载zsh扩展
|
||||||
ohmyzsh_dir=${ROOT_INSTALL}/oh-my-zsh
|
ohmyzsh_dir=${ROOT_INSTALL}/oh-my-zsh
|
||||||
git clone https://gitcode.com/mirrors/ohmyzsh/ohmyzsh.git ${ohmyzsh_dir}
|
sudo git clone https://gitcode.com/mirrors/ohmyzsh/ohmyzsh.git ${ohmyzsh_dir}
|
||||||
cd -v ${ohmyzsh_dir}/custom/plugins/
|
cd ${ohmyzsh_dir}/custom/plugins/
|
||||||
git clone https://gitcode.com/mirrors/zsh-users/zsh-autosuggestions.git
|
sudo git clone https://gitcode.com/mirrors/zsh-users/zsh-autosuggestions.git
|
||||||
git clone https://gitcode.com/mirrors/zsh-users/zsh-syntax-highlighting.git
|
sudo 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
|
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
|
ColorReset
|
||||||
Show 2 "寻觅基础环境安装完成"
|
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
|
Install_Zsh
|
||||||
Download_Config
|
Download_Config
|
||||||
|
Select_Config
|
||||||
|
3
配置/zshrc
3
配置/zshrc
@ -66,7 +66,8 @@ plugins=(
|
|||||||
zsh-syntax-highlighting
|
zsh-syntax-highlighting
|
||||||
)
|
)
|
||||||
|
|
||||||
source /usr/share/doc/pkgfile/command-not-found.zsh
|
# arch系列安装pkgfile后可以使用其内置的command-not-found功能
|
||||||
|
# source /usr/share/doc/pkgfile/command-not-found.zsh
|
||||||
|
|
||||||
source $ZSH/oh-my-zsh.sh
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user