前提:安装好Git

1、安装zsh并更改默认终端

安装软件包

1
yum -y install zsh git

更改默认终端

1
chsh -s /bin/zsh

2、配置oh-my-zsh

拉取oh-my-zsh

1
git clone https://gitee.com/mirrors/oh-my-zsh.git ~/.oh-my-zsh

默认配置

1
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

3、安装高亮、自动补全插件

安装高亮插件:zsh-syntax-highlighting

1
git clone https://gitee.com/dawnwords/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

安装自动补全:zsh-autosuggestions

1
2
git clone https://gitee.com/lhaisu/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

安装autojump目录跳转

1
2
3
git clone https://gitee.com/gentlecp/autojump.git
cd autojump
./install.py

4、插件配置

1
vim ~/.zshrc
1
2
3
4
5
6
7
plugins=(
git
sudo
zsh-autosuggestions
zsh-syntax-highlighting
autojump
)
1
source ~/.zshrc

5、修改主题

1
vim ~/.zshrc

个人比较喜欢这套

1
ZSH_THEME="maran"

除了自带的两个主题外我个人还比较喜欢两个

分别是sobole和jovial

  • sobole

    74af970abbf731048fef10bb85c0b92b.png

  • jovial

    48ada5d75ea2044b132b85bc106b2ae3.png

screenshot

sobole安装地址:

sobolevn/dotfiles: dotfiles for the developer happiness: macos, zsh, brew, vscode, codespaces, python, node, elixir (github.com)

jovial安装地址:

zthxxx/jovial: Jovial - A lovely zsh theme with responsive-design, it’s pretty fast, keep simple but useful (github.com)

dracula-theme安装地址

Dark theme for Zsh and 266+ apps — Dracula (draculatheme.com)

1
source ~/.zshrc

6、其他

zsh粘贴慢问题:一个字符一个字符粘贴。这是zsh的问题

解决:修改zsh配置:vim ~/.zshrc,增加如下代码:

1
vim ~/.zshrc
1
2
3
4
5
6
7
8
9
10
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
}

pastefinish() {
zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish
1
source ~/.zshrc

LAST:效果展示

美化前:

image-20231108204645514

美化后:

image-20231108204754639