平时Mac使用的shell使bash, 它虽然能满足我们的需要, 但是使用起来不是很方便. zsh可配置性强, 用户可以自定义配置, 个性化强.
更换shell
查看当前使用的shell
echo $SHELL
1 | /bin/bash |
查看系统当前内置的shell
cat /etc/shells
1 | /bin/bash |
如果没有发现/bin/zsh, 就需要手动安装Zsh.
替换shell
chsh -s /bin/zsh
1 | Changing shell for **. |
重启
echo $SHELL
1 | /bin/zsh |
替换成功!
安装oh-my-zsh
oh-my-zsh用来管理Zsh配置的.
安装
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)".
1 | Looking for an existing zsh config... |
更改配置
vim ~/.zshrc
1 | # Set name of the theme to load --- if set to "random", it will |
以上是部分配置, 需将#
删除才能生效. 键入i
进入编辑模式, 修改后esc
退出编辑模式, 键入:wq
保存退出. oh-my-zsh有支持的主题和插件, 可以自由配置.
插件推荐
zsh-syntax-highlighting
安装zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
修改配置(zsh-syntax-highlighting)
vim ~/.zshrc
1 | plugins=( |
让修改生效(zsh-syntax-highlighting)
source ~/.zshrc
zsh-autosuggestions
安装zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
修改配置(zsh-autosuggestions)
vim ~/.zshrc
1 | plugins=( |
让修改生效(zsh-autosuggestions)
source ~/.zshrc
好了, 打完收工!