-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_ohmyzsh_deb.sh
86 lines (86 loc) · 2.41 KB
/
install_ohmyzsh_deb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# 更新软件包索引
apt update
# 安装Z shell
apt install -y zsh
# 下载Oh My Zsh安装脚本
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
# 检查Oh My Zsh仓库目录是否存在
if [ ! -d "~/.oh-my-zsh" ]; then
echo "Oh My Zsh仓库克隆失败。"
# 尝试使用第二个命令克隆Oh My Zsh仓库
git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
fi
# 备份
cp .zshrc .zshrc.bak
if [ $? -eq 0 ];then
echo "备份.zshrc成功"
else
echo "备份.zshrc失败"
exit 1
fi
# 复制配置文件到根目录
cp ~/.oh-my-zsh/templates/zshrc.zsh-template .zshrc
if [ $? -eq 0 ];then
echo "复制配置文件成功"
else
echo "复制配置文件失败"
exit 1
fi
# 切换默认shell为zsh
chsh -s $(which zsh)
# 修改全局配置,对所有的用户生效
echo "/root/.zshrc" >> /etc/zshrc
# 更改新用户的默认shell
cp /etc/default/useradd /etc/default/useradd.back
sed -i '8,11 s/^/# /' /etc/default/useradd
echo "SHELL=/bin/zsh" >> /etc/default/useradd
# 查看当前目录隐藏文件
ls -als
# 切换到ohmyzsh主题目录
cd ~/.oh-my-zsh/themes
# 克隆Powerlevel10k主题
git clone https://github.com/romkatv/powerlevel10k.git
# 检查Powerlevel10k主题是否存在
if [ ! -d "powerlevel10k" ]; then
echo "Powerlevel10k主题克隆失败。"
exit 1
fi
# 查看当前目录隐藏文件
ls -als
# 切换到ohmyzsh插件目录
cd ~/.oh-my-zsh/plugins
# 克隆zsh-autosuggestions插件
git clone https://github.com/zsh-users/zsh-autosuggestions
# 克隆zsh-syntax-highlighting插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# 克隆zsh-completions插件
git clone https://github.com/zsh-users/zsh-completions
# 检查克隆的目录是否存在
if [ ! -d "zsh-autosuggestions" ]; then
echo "克隆zsh-autosuggestions插件失败。"
exit 1
fi
if [ ! -d "zsh-syntax-highlighting" ]; then
echo "克隆zsh-syntax-highlighting插件失败。"
exit 1
fi
if [ ! -d "zsh-completions" ]; then
echo "克隆zsh-completions插件失败。"
exit 1
fi
# 所有插件克隆成功
echo "成功克隆所有插件!"
# 切换到根目录
cd ~/
# 配置.zshrc文件
cp .zshrc .zshrc.back
if [ $? -eq 0 ];then
echo "备份.zshrc成功"
else
echo "备份.zshrc失败"
exit 1
fi
# 安装完成
echo "Zsh, Oh My Zsh, Powerlevel10k, zsh-autosuggestions, zsh-syntax-highlighting, and zsh-completions have been installed and configured."
exit 0