zsh plugins like fish shell

fish shell 相比较 zsh(oh-my-zsh) 提供了一些比较炫酷的特性, 详见官网 fishshell

其中主要有两个特性非常有吸引力:

  • 智能提示(Autosuggestions)
  • 语法高亮(Glorious VGA Color)

但是搜索后发现,使用过fish的同学大多最终都回归了zsh, 主要因为fish有如下问题:非标准shell坑多、无插件机制、不兼容vim等

那么问题来了,zsh 是否有类似比较炫酷的功能呢?

答案是肯定的(好的特性总是会相互学习),在 zsh-users(zsh community projects) 中有两个插件插件实现了相同的特性:

install plugins

1
2
3
4
5
6
7
8
9
10
11
12
# clone plugins
git clone https://github.com/zsh-users/zsh-autosuggestions.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# config ~/.zshrc
# plugins=( [plugins...] zsh-autosuggestions zsh-syntax-highlighting)

# source config
source ~/.zshrc

zsh-autosuggestions

根据 shell history 进行智能提示

zsh-autosuggestions

zsh-syntax-highlighting

图中可以看到 echo 是绿色的,代表存在这个命令,如果打错了(git),就显示是红色的

zsh-syntax-highlighting