ZSH配置

  • 安装zsh
1
sudo apt install zsh
  • 切换到zsh
1
chsh -s /usr/bin/zsh

注销后重新登陆,进入zsh配置界面,根据提示进行配置

  • 安装插件
1
sudo apt-get install zsh-autosuggestions zsh-syntax-highlighting
  • 启用插件

打开 ~/.zshrc 添加如下配置

1
2
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  • 安装主题 powerlevel10k

根据 powerlevel10k 文档安装字体,对使用的终端进行配置

1
2
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc

配置完成后会进入配置界面,根据提示进行配置即可

  • 安装fzf
1
2
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
  • 配置文件

打开 ~/.zshrc 添加如下配置,增加ctrl+r按键绑定

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
bindkey '^R' history-incremental-search-backward

# bash rc
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

参考

配置一个简洁高效的 Zsh | Linux 中国
计算机教育中缺失的一课-Shell 工具和脚本