1.安装zsh

sudo pacman -S zsh

2.设置默认zsh
列出所有已安装shell

chsh -l

要为您的用户设置一个默认值

chsh -s /full/path/to/shell

例如

chsh -s /usr/bin/zsh

3.注销并再次登录,打开shell
这时会看到

This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

--- Type one of the keys in parentheses --- 

输入0就会退出并生成配置文件~/.zshrc

4.安装插件

sudo pacman -S zsh-autosuggestions zsh-completions zsh-history-substring-search zsh-syntax-highlighting

zsh-autosuggestions 给出补全建议
zsh-completion 应该是强化补全
zsh-history-substring-search 输入一部分命令后根据历史补全,需要快捷键
zsh-syntax-highlighting 语法高亮 目前我知道正确是绿色 错误是红色

5.设置配置

vim ~/.zshrc

在~/.zshrc中输入以下配置,可放大查看

#环境变量

# 配置
PROMPT='%F{13}[%n@%m %#]%f'

# 历史记录
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000

# 快捷键
bindkey '^P' history-search-backward
bindkey '^N' history-search-forward

# 设置标题
autoload -Uz add-zsh-hook

function xterm_title_precmd () {
	print -Pn -- '\e]2; %~\a'
	[[ "$TERM" == 'screen'* ]] && print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-}\e\\'
}

function xterm_title_preexec () {
	print -Pn -- '\e]2; %~ %# ' && print -n -- "${(q)1}\a"
	[[ "$TERM" == 'screen'* ]] && { print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-} %# ' && print -n -- "${(q)1}\e\\"; }
}

if [[ "$TERM" == (Eterm*|alacritty*|aterm*|foot*|gnome*|konsole*|kterm*|putty*|rxvt*|screen*|wezterm*|tmux*|xterm*) ]]; then
	add-zsh-hook -Uz precmd xterm_title_precmd
	add-zsh-hook -Uz preexec xterm_title_preexec
fi

# 插件
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh

# 高亮颜色
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=#FF7B7B'
ZSH_HIGHLIGHT_STYLES[command]='fg=#8DFF7B'
ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=#ED80FF'
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=#78ECFF'
ZSH_HIGHLIGHT_STYLES[path]='fg=#78ECFF'
ZSH_HIGHLIGHT_STYLES[precommand]='fg=#F5FF7D'
ZSH_HIGHLIGHT_STYLES[builtin]='fg=#FFD37F'

配置这一项是设置命令提示符,显示用户名主机名 权限
历史记录是设置记录命令输入历史
快捷键是在输入部分命令后用ctrl+n ctrl+p键根据历史命令记录进行补全
设置标题显示工作路径 权限和命令
source zsh的高亮脚本要放在配置结尾:参照 https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md
命令提示符配置wiki https://www.newverse.wiki/knows/prompt/