环境

Debian 最小化安装环境

安装 ZSH

1
apt install zsh git -y

配置 oh-my-zsh

1
2
3
4
5
6
7
8
9
# 官方 推荐!
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"


# 国内镜像源(每日更新一次)
git clone https://gitee.com/mirrors/oh-my-zsh.git ~/.oh-my-zsh

# 默认配置
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

更改默认终端

如果使用官方推荐方式则跳过这一步

1
2
chsh -s /usr/bin/zsh
zsh

这时候打开终端软件,应该就会默认进入 zsh 了。

如果 shell 连接进入 bash 则需要重启一下系统

安装插件

快捷安装以下插件

1
apt install zsh-syntax-highlighting zsh-autosuggestions autojump -y

zsh-syntax-highlighting 命令高亮插件

1
apt install zsh-syntax-highlighting -y

zsh-autosuggestions 自动建议补全

1
apt install zsh-autosuggestions -y

安装 autojump 目录跳转

1
apt install autojump -y

插件配置

同样是打开.zshrc 文件,找到 plugins=(git),在这里增加自己想要的插件即可,多个插件名称之间使用空格或者换行分开(不能使用逗号)。
vim ~/.zshrc

1
2
3
4
5
6
7
8
9
10
ZSH_THEME="steeef"

plugins=(
git
sudo
autojump
)

source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# 其他配置

.zshrc

1
2
3
4
5
6
7
8
9
10
11
12
13
# 自动更新不需要确认
zstyle ':omz:update' mode auto

# 禁用更新
# zstyle ':omz:update' mode disabled

# 防止通配符报错
setopt no_nomatch


# 设置别名
alias la="ls -la"

每次修改完 .zshrc 都需要

1
source ~/.zshrc

source /etc/profile

如果将 source /etc/profile 放入 .zshrc 中,会覆盖 zsh 的样式。因此,需要对代码进行修改。(也就是删除中间一段代码)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
root at feng in ~ 
$ cat /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$(id -u)" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH

if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi

推荐主题

默认 robbyrussell

简约 steeef

https://minio.kl.do/picture/images/blog/6a401e38d1ad71581625915c3c09dc9b.png