安装脚本

(推荐) 完全体 安装两分钟左右:

1
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

精简版:

1
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" speed

最推荐方式:

1
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

安装完成后输入brew -v遇到问题:

1
2
3
4
5
6
7
8
9
10
fatal: detected dubious ownership in repository at '/opt/homebrew/Library/Taps/homebrew/homebrew-core'
To add an exception for this directory, call:

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core (no Git repository)
fatal: detected dubious ownership in repository at '/opt/homebrew/Library/Taps/homebrew/homebrew-cask'
To add an exception for this directory, call:

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask (no Git repository)

解决办法(根据提示,执行命令):

1
2
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask

卸载脚本

1
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"

常用命令

查找:

1
brew search git

下载:

1
brew install git

重新下载;

1
brew reinstall git

卸载:

1
brew uninstall git

ohmyzsh

我尝试了官网的命令下载,不行,链接不上主机。

下载 oh-my-zsh 的下载命令:

1
wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh

添加可执行权限:

1
chmod +x install.sh

执行 install.sh

1
./install.sh

修改配置:

  • 环境变量:

    将第二排的 # 号删就可以加载原本配置在 bash 中的环境了。当然还可以在后面加两行,更保险:

    1
    2
    source /etc/profile
    source ~/.bash_profile
  • 主题:

    1
    ZSH_THEME="robbyrussell"

    改为:

    可以在 oh-my-zsh 官网点击 themes 跳转查看各种主题。

    我比较喜欢:jonathan

    大家一般推荐:

    1
    ZSH_THEME="ys"

    当然也可以选择 powerlevel10k,但是要配置很多东西,我也不太喜欢,即没弄。

  • 修改插件:

    1
    plugins=(git)

    改为(添加代码高亮和代码建议):

    1
    plugins=(git zsh-syntx-highlighting zsh-autosuggestions)

    如果 not found:

    1
    2
    3
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

    最后

    1
    source ~/.zshrc