在Windows拥有Zsh

在Windows拥有Zsh

首先你要先安装好Ubuntu Bash,此处教程.

安装zsh

1
$ sudo apt-get install zsh

启动zsh

1
$ zsh

键入2创建配置文件

若要退出zsh回到Bash

1
$ exit

设置zsh默认启动

打开配置文件~/.bashrc

1
$ vim ~/.bashrc

在文件中加入如下几行
1
# Launch Zsh
2
if [ -t 1 ]; then
3
exec zsh
4
fi

安装Oh My Zsh

1
$ curl -L https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash
2
  # 把 Zsh 设置为当前用户的默认 Shell
3
$ chsh -s /bin/zsh

设置主题
编辑~/.zshrc

1
$ vim ~/.zshrc

修改主题为
1
ZSH_THEME="amuse"

这个主图需要下载字体
其一 Meslo LG M Regular for Powerline.ttf
更多字体

安装语法高亮插件

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

配置文件
1
$ vim ~/.zshrc

找到这行
1
plugins=(git)

改为
1
plugins=(git zsh-syntax-highlighting)

保存退出然后更新设置
1
$ source ~/.zshrc

有可能会碰到这样的报错

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

我最后选择了最次的方法
配置文件
1
$ vim ~/.zshrc


1
export ZSH="/home/Benature/.oh-my-zsh"

前加一行
1
ZSH_DISABLE_COMPFIX=true
2
  export ZSH="/home/Benature/.oh-my-zsh"


参考资料