在Windows拥有Zsh
首先你要先安装好Ubuntu Bash,此处教程.
安装zsh1
sudo apt-get install zsh
启动zsh1
zsh
键入2
创建配置文件
若要退出zsh回到Bash1
exit
设置zsh默认启动
打开配置文件~/.bashrc
1
vim ~/.bashrc
在文件中加入如下几行1
2
3
4# Launch Zsh
if [ -t 1 ]; then
exec zsh
fi
安装Oh My Zsh1
2
3curl -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
2ZSH_DISABLE_COMPFIX=true
export ZSH="/home/Benature/.oh-my-zsh"
参考资料
- https://www.howtogeek.com/258518/how-to-use-zsh-or-another-shell-in-windows-10/
- https://evdokimovm.github.io/windows/zsh/shell/syntax/highlighting/ohmyzsh/hyper/terminal/2017/02/24/how-to-install-zsh-and-oh-my-zsh-on-windows-10.html
- https://benature.github.io/2019/01/18/Terminal_in_Mac_configuration/