0%

在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
2
3
4
# Launch Zsh
if [ -t 1 ]; then
exec zsh
fi

安装Oh My Zsh

1
2
3
$ curl -L https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash
# 把 Zsh 设置为当前用户的默认 Shell
$ 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
2
3
4
5
6
7
8
9
10
11
12
13
[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.

[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh] compaudit | xargs chmod g-w,o-w

[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[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
2
ZSH_DISABLE_COMPFIX=true
export ZSH="/home/Benature/.oh-my-zsh"


参考资料