MacOS 10.15 Catalina 安装 oh-my-zsh

从 macOS Catalina 版开始,您的 Mac 将使用 zsh 作为默认登录 Shell 和交互式 Shell。您还可以在较低版本的 macOS 中将 zsh 设置为默认 Shell。
默认情况下,您的 Mac 使用 zsh 或 bash 作为登录 Shell 和交互式 Shell 的命令行解释器:

· 从 macOS Catalina 版开始,zsh (Z shell) 是所有新建用户帐户的默认 Shell。
· bash 是 macOS Mojave 及更低版本中的默认 Shell。

zsh 与 Bourne Shell (sh) 高度兼容,并且与 bash 基本兼容,但存在一些差别。要进一步了解 zsh 及其全面的命令行完成系统,请在“终端”中输入 man zsh。

===========================
以上是苹果说明原文,在 Catalina 以前我们都需要安装 zsh 跟 oh-my-zsh,现在我们只需要安装 oh-my-zsh 就能提升我们的工作效率。

1.安装 oh-my-zsh

由于 GitHub 的地址:githubusercontent.com被墙,软件级插件链接替换成国内 Gitee 镜像地址。

sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

2.安装插件

cd ~/.oh-my-zsh/custom

# 安装zsh-syntax-highlighting

git clone https://gitee.com/pankla/zsh-syntax-highlighting.git ./plugins/zsh-syntax-highlighting

# 安装zsh-autosuggestions

git clone https://gitee.com/pankla/zsh-autosuggestions.git ./plugins/zsh-autosuggestions

3. 修改.zshrc

在文件 71 行的位置注释plugins=(git)

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
#把这个注释掉plugins=(git)

source $ZSH/oh-my-zsh.sh

# User configuration

在文件底部添加以下内容

#插件
plugins=(git z extract web-search zsh-syntax-highlighting zsh-autosuggestions osx)

#zsh-syntax-highlighting

export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=$ZSH_CUSTOM/plugins/zsh-syntax-highlighting/highlighters
source $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

#zsh-autosuggestions
source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

保存退出后,使之生效

source .zshrc

4. 错误提示

这个提示,主要是因为/usr/local/share/zsh/usr/local/share/zsh/site-functions/权限过高导致的。

[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxr-x  3 panda  admin  96 11  9 02:14 /usr/local/share/zsh/
drwxrwxr-x  3 panda  admin  96 11  9 02:14 /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.

修改文件夹属性即可消除错误提示

chmod 755 /usr/local/share/zsh/
chmod 755 /usr/local/share/zsh/site-functions/

重新输入source .zshrc错误消失,大功告成。

[2020-11-9|5:17:04]# panda@PandaMan-MacBook-Pro 192.168.10.6 ~ >
» source .zshrc                                                                                   [0]↵

[2020-11-9|5:17:35]# panda@PandaMan-MacBook-Pro 192.168.10.6 ~ >
»                                                                                                 [0]↵

欢迎尝试我的 oh-my-zsh 个性主题 – Panda

MacOS 的 oh-my-zsh 就介绍到这里,有任何问题欢迎留言交流。

You may also like...

1个回复

  1. film说道:

    Hi there, yup this paragraph is genuinely pleasant and I have learned lot of things from it regarding blogging. Minta Bern Obala

发表评论

电子邮件地址不会被公开。 必填项已用*标注