oh-my-fishy-zsh配置

都说普通青年用bash,装逼青年用zsh,文艺青年用fish。

fish是真的好用,但是它最大的问题是与bash不兼容,从而带来各种各样兼容性问题,折腾过fish的人都知道。而zsh有着可定制化的oh-my-zsh框架,同时又是兼容bash语法的,笔者在这里记录一下如何安装一个oh-my-fishy-zsh。

前置环境安装

环境参数

1
2
3
4
5
6
7
8
clhu@t5 ~> uname -a
Linux t5 4.15.0-48-generic #51~16.04.1-Ubuntu SMP Fri Apr 5 12:01:12 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
clhu@t5 ~> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial

安装zsh

1
sudo apt-get install zsh curl git

安装oh-my-zsh

安装过程中会自动切换默认的shell为zsh

1
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

自定义你的.zshrc

安装完oh-my-zsh的下一步就是自定义配置文件,下面罗列了一些模仿fish必备的插件

fishy主题

zsh主题选择fishy,可以模仿fish特有的路径简写模式。

1
ZSH_THEME="fishy"

插件清单

1
2
3
4
5
6
7
8
9
10
11
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
zsh-completions
z
history-substring-search
command-not-found
colored-man-pages
extract
)
  • git: 提示当前目录所在git仓库的状态的插件
  • z: 可以无脑跳跃到历史记录中出现过的文件夹中
  • command-not-found:会自动根据出错的命令,推荐该命令可能相关的包
  • colored-man-pages: 给man page自动高亮,命令行神器
  • extract: 只需要一个x就可以解压任何压缩包,再也不需要手打tar xfvz
  • zsh-syntax-highlighting: 模仿fish命令行高亮的插件
1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
1
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  • zsh-completions: 自动命令补全,类似bash-completions功能的插件
1
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions
1
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search

最终效果

配置完成之后的效果如下图所示

zsh