Linux 安装并配置zsh

1. 安装zsh,配置agnoster主题

1.1 安装zsh

$ sudo apt-get install -y zsh

1.2 安装oh-my-zsh

$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

1.3 安装powerline font字体库

$ sudo apt-get install fonts-powerline

1.4 打开zsh配置文件 ~/.zshrc,修改主题为agnoster

1 # Set name of the theme to load --- if set to "random", it will
2 # load a random theme each time oh-my-zsh is loaded, in which case,
3 # to know which specific one was loaded, run: echo $RANDOM_THEME
4 # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
5 ZSH_THEME="agnoster"

1.5 将zsh设置为默认终端

$ chsh -s `which zsh`

1.6 注销,重新登陆

$ logout

2. 安装插件

2.1 进入插件路径

$ cd ~/.oh-my-zsh/plugins

2.2 下载自动补齐、高亮、建议插件

$ wget http://mimosa-pudica.net/src/incr-0.2.zsh
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
$ git clone https://github.com/zsh-users/zsh-autosuggestions
$ source incr*.zsh

2.3 修改配置文件

$ vi ~/.zshrc
1 plugins=(git
2 zsh-syntax-highlighting
3 zsh-autosuggestions)
4 
5 source ~/.oh-my-zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

2.4 可能会出现的问题

2.4.1 compaudit | xargs chmod g-w,o-w
 1 [oh-my-zsh] Insecure completion-dependent directories detected:
 2 drwxrwxrwx   7 pi pi 640 12 16 09:03 /home/pi/.oh-my-zsh
 3 
 4 [oh-my-zsh] For safety, we will not load completions from these directories until
 5 [oh-my-zsh] you fix their permissions and ownership and restart zsh.
 6 [oh-my-zsh] See the above list for directories with group or other writability.
 7 
 8 [oh-my-zsh] To fix your permissions you can do so by disabling
 9 [oh-my-zsh] the write permission of "group" and "others" and making sure that the
10 [oh-my-zsh] owner of these directories is either root or your current user.
11 [oh-my-zsh] The following command may help:
12 [oh-my-zsh]     compaudit | xargs chmod g-w,o-w
13 
14 [oh-my-zsh] If the above didn't help or you want to skip the verification of
15 [oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
16 [oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.

只需要按照提示,键入 compaudit | xargs chmod g-w,o-w