From a6d3494fc537c6741ef238179de77ce1fb673e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AF=BB=E8=A7=85?= Date: Fri, 2 Feb 2024 00:15:11 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96]=20=E4=BC=98=E5=8C=96=20sta?= =?UTF-8?q?rt.sh=20=E5=AE=89=E8=A3=85=E8=84=9A=E6=9C=AC,=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0=E7=9A=84=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- start.sh | 43 +++++++++++++++++++++++++------------------ 安装.zsh | 26 ++++++++++++++------------ 3 files changed, 40 insertions(+), 31 deletions(-) mode change 100644 => 100755 安装.zsh diff --git a/README.md b/README.md index c3c8442..ef0a8e4 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ 寻觅使用的Linux配置脚本 -如无zsh请先使用 `wget -qO- https://gitea.whlug.cn/xunmi/getLinux/raw/start.sh | bash` 命令安装基础模块 +如无zsh请先使用 `wget -O- https://gitea.whlug.cn/xunmi/x/raw/start.sh | bash` 命令安装基础模块 diff --git a/start.sh b/start.sh index c9ebfa7..c4b6616 100755 --- a/start.sh +++ b/start.sh @@ -3,10 +3,9 @@ # wget -qO- https://gitea.whlug.cn/xunmi/getLinux/raw/start.sh | bash PACK_LIST=("wget" "git" "zsh") # 脚本根地址 -ROOT_URL="https://gitea.whlug.cn/xunmi/getLinux/" +ROOT_URL="https://gitea.whlug.cn/xunmi/x/" # 插件和依赖安装的路径 ROOT_INSTALL=/opt/xunmi - ############################################################################### # 终端配色 # ############################################################################### @@ -22,19 +21,15 @@ readonly aCOLOUR=( ) Show() { - # OK if (($1 == 0)); then echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} 成功 $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" - # FAILED elif (($1 == 1)); then echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]} 失败 $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" exit 1 - # INFO elif (($1 == 2)); then echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]} 信息 $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" - # NOTICE elif (($1 == 3)); then - echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[5]} 警告 $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" + echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[5]} 通知 $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" fi } @@ -56,7 +51,7 @@ ColorReset() { # 选择判断器 Select_Continue() { - Show 0 "$1((是/否 Yes/No))" + Show 3 "$1((是/否 Yes/No))" read r if echo "$r" | grep -Eq "^[是Yy][Ee]?[Ss]?$";then return 0 @@ -89,8 +84,8 @@ Install_Zsh() { sudo apt -y install $pack elif [ -x "$(command -v yum)" ]; then sudo yum install -y $pack - elif [ -x "$(command -v pacman)" ]; then - sudo -Sy --needed $pack + elif [ -x "$(command -v pacman)" ]; then + sudo pacman -Sy --needed $pack #elif [ -x "$(command -v paru)" ]; then # paru -S zsh else @@ -108,32 +103,44 @@ Download_Config() { # 下载zsh扩展 GreyStart ohmyzsh_dir=${ROOT_INSTALL}/oh-my-zsh - sudo git clone https://gitcode.com/mirrors/ohmyzsh/ohmyzsh.git ${ohmyzsh_dir} || Show 1 "关键依赖下载失败, 如${ohmyzsh_dir}已存在, 请先删除 \nsudo rm -rf ${ROOT_INSTALL}" + sudo rm -vrf $ohmyzsh_dir + sudo git clone https://gitcode.com/mirrors/ohmyzsh/ohmyzsh.git ${ohmyzsh_dir} || Show 1 "关键依赖下载失败" 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})" + config_url=${ROOT_URL}raw/配置/zshrc + sudo wget -t 3 -q --show-progress -c "${config_url}" || Show 1 "无法下载预设配置( ${config_url} )" sudo 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 + cd $HOME ColorReset Show 2 "寻觅基础环境安装完成" } # 选配 Select_Config(){ - if Select_Continue "启动zsh"; then - exec zsh - Show 2 "zsh启动完成" - fi if Select_Continue "将Zsh设置为默认命令行"; then chsh -s /usr/bin/zsh - Show 2 "已将zsh设置为默认命令行" + Show 0 "已将zsh设置为默认命令行" + else + Show 2 "如需将zsh设置为默认命令行请执行: 'chsh -s /usr/bin/zsh' " fi + + if Select_Continue "启动zsh"; then + Show 0 "将在程序结束后启动zsh" + ZSH_START=1 + else + Show 2 "zsh未启动, 如需启动请执行: 'zsh' " + fi + } Install_Zsh Download_Config Select_Config + +if [ "$ZSH_START" ]; then + exec zsh +fi diff --git a/安装.zsh b/安装.zsh old mode 100644 new mode 100755 index f1d2d15..4c59a67 --- a/安装.zsh +++ b/安装.zsh @@ -72,6 +72,16 @@ readonly 色彩=( ############################################################################### # 函数/方法 # ############################################################################### +是否() { + 输出 3 "$1((是/否 Yes/No))" + read r + if echo "$r" | grep -Eq "^[是Yy][Ee]?[Ss]?$";then + return 0 + else + return 1 + fi +} + 检查_架构() { case ${CPU_架构} in @@ -104,18 +114,10 @@ readonly 色彩=( esac 输出 2 "检测到 ${系统_发行版_名称} (${系统_发行版}) 系统" if [[ ${未知} == 1 ]]; then - 输出 3 "此发行版尚未被验证,是否继续尝试安装(请谨慎安装)" - select 是否 in "[是] Yes" "[否] No"; do - case ${是否} in [yY][eE][sS] | [yY] | [是]) - 输出 2 "发行版检查已忽略" - break - ;; - [nN][oO] | [nN] | [否]) - 输出 1 "已退出安装" - exit 1 - ;; - esac - done < /dev/tty # < /dev/tty 用于从终端读取输入信息 + if ! 是否 "此发行版尚未验证, 是否尝试继续安装"; then + 输出 1 "已退出安装" + exit 1 + fi fi }