养成类虚拟机 --- 配置ZSH
Mr.Lee 2024-04-21 11:53:00 LinuxVM
我现在有三台虚拟机 10.13.147.9
, 10.13.147.10
, 10.13.147.11
配置一下ZSH
下面以一台机器为例记录, 配置过程
# 1. 安装Git
apt update -y
apt install -y git
1
2
2
# 2. 安装Zsh
apt install -y zsh
# #将zsh设置成默认shell
chsh -s /bin/zsh
1
2
3
2
3
# 3. 基础配置
# 安装 oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# 下载主题
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
# 修改ZSH配置文件, 设置主题
vim ~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"
# 设置系统语言为中文
export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
# 配置文件生效
source ~/.zshrc
# 允许 root 用户登录
vim /etc/ssh/sshd_config
PermitRootLogin yes
systemctl restart sshd
# 检查是否已安装 Netplan
dpkg -l | grep netplan
# 安装 Netplan
sudo apt install -y netplan.io
# 配置 Netplan
mkdir -p /etc/netplan
vim /etc/netplan/00-installer-config.yaml
cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens160:
dhcp4: false
addresses:
- 10.13.147.13/24
routes:
- to: default
via: 10.13.147.2
nameservers:
addresses:
- 8.8.8.8
- 4.4.4.4
- 10.13.147.2
version: 2
# 禁用传统网络配置
mv /etc/network/interfaces /etc/network/interfaces.bak
touch /etc/network/interfaces # 创建空文件
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
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
# 4. 安装Zsh插件
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions
1
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
1
git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
1
参考文章:
- https://www.swtestacademy.com/customize-mac-terminal/
- https://holychung.medium.com/%E5%88%86%E4%BA%AB-oh-my-zsh-powerlevel10k-%E5%BF%AB%E9%80%9F%E6%89%93%E9%80%A0%E5%A5%BD%E7%9C%8B%E5%A5%BD%E7%94%A8%E7%9A%84-command-line-%E7%92%B0%E5%A2%83-f66846117921