admin 管理员组文章数量: 1087652
Oh My ZSH让你的终端美如画
文章目录
- 前言
- 安装方法
- 安装高亮显示插件
- 智能提示 zsh-autosuggestions
- 主题设置
- 设置 vim 可配色
- 临时不想用Oh My ZSH
- 方法一:
- 方法二:
- 卸载
- 参考文档
前言
无意中发现这个插件Oh My ZSH,之前也有在一些视频中看到过,一直好奇是什么插件。怎么早没发现这么好用的插件啊。
安装方法
官网:
/
sh -c "$(curl -fsSL .sh)"
国内源加速:
sh -c "$(curl -fsSL .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 .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
智能提示 zsh-autosuggestions
cd $HOME/.oh-my-zsh/plugins
#下载代码
git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
修改~/.zshrc
增加插件引用
plugins=(zsh-autosuggestions)
主题设置
如多主题到这里看吧:
我挑一个自己喜欢的主题。
这主题要先安装字体:
- 安装 powerline 字体
# clone
git clone .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 可配色
终端输入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
重启以后它就没有了。变回它原来的样子了。
友情提醒:卸载会把你安装的插件一起卸载了,如果觉得有需要就备份一下吧。
参考文档
本文标签: Oh My ZSH让你的终端美如画
版权声明:本文标题:Oh My ZSH让你的终端美如画 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1686637619a20302.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论