- 前言
- 安装方法
- 安装高亮显示插件
- 智能提示 zsh-autosuggestions
- 主题设置
- 设置 vim 可配色
- 临时不想用Oh My ZSH
- 方法一:
- 方法二:
- 卸载
- 参考文档
无意中发现这个插件Oh My ZSH,之前也有在一些视频中看到过,一直好奇是什么插件。怎么早没发现这么好用的插件啊。
官网: https://ohmyz.sh/
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
国内源加速:
sh -c "$(curl -fsSL https://gitee.com/lxyoucan/tools/raw/master/common/ohmyzshinstall.sh)"
安装完成后,打开终端会出现:
[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxrwx 3 itkey admin 96 12 17 10:26 /usr/local/share/zsh
drwxrwxrwx 4 itkey admin 128 12 17 10:29 /usr/local/share/zsh/site-functions
[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.
根据提示,执行以下语句:
compaudit | xargs chmod gw,ow
下次打开终端就没有这个提示了。
安装高亮显示插件我首先要做的是安装一个名为 zsh-syntax-highlighting的插件。它为ZSH Shell提供语法高亮显示。
cd $HOME/.oh-my-zsh/plugins
#下载代码
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
#自动配置
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
最后一行,就是自动修改 ~/.zshrc,在最后一行加入
source /Users/itkey/.oh-my-zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
cd $HOME/.oh-my-zsh/plugins
#下载代码
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
修改~/.zshrc
增加插件引用 plugins=(zsh-autosuggestions)
如多主题到这里看吧: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
我挑一个自己喜欢的主题。 这主题要先安装字体:
- 安装 powerline 字体
# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts
- iTerm中设置字体
- 修改
~/.zshrc
ZSH_THEME=“agnoster”
VSCODE中设置 在你的设置文件中 (Code | Preferences | Settings)
增加如下这行:
"terminal.integrated.fontFamily": "Meslo LG S DZ for Powerline"
终端输入vim .vimrc,设置内容如下,
syntax on
set number
set ruler
临时不想用Oh My ZSH
如果体验以后,发现可能不适合你。或者都临时换成以前的zsh怎么办呢? 肉吃多了想吃点素的。
zsh -f
这只是临时的,下次打开终端还是会以 Oh My ZSH打开。
方法二:安装Oh My ZSH以前会自动把我们之前的~/.zshrc ,重命名为~/.zshrc.pre-oh-my-zsh
。 修改~/.zshrc
为安装Oh My ZSH这前的配置即可。
- 从
Oh My ZSH
切换到ZSH
#备份Oh My ZSH的配置,方便后面还原
cp ~/.zshrc ~/.zshrc.bak-oh-my-zsh
#切换为原配置
cp ~/.zshrc.pre-oh-my-zsh ~/.zshrc
- 从
ZSH
切换到Oh My ZSH
#前提是之前执行过从Oh My ZSH切换到ZSH
cp ~/.zshrc.bak-oh-my-zsh ~/.zshrc
重新开启终端生效。反正就捣鼓这两个文件~/.zshrc
和 ~/.zshrc.pre-oh-my-zsh
,如果你喜欢可以把这个操作做成快捷指令方便来回切换。
这么好的东西你要卸载了?心不会痛吗?好吧,那么它来了。
uninstall_oh_my_zsh
重启以后它就没有了。变回它原来的样子了。 友情提醒:卸载会把你安装的插件一起卸载了,如果觉得有需要就备份一下吧。
https://dev.to/amanhimself/setup-macbook-m1-for-web-and-react-native-development-8la