# zshrc配置

# 安装ohmyzsh

1
sh -c "$(curl -fsSL [**https://gitee.com/hubmirror/ohmyzsh/blob/master/oh-my-zsh.sh**](https://gitee.com/jklash1996/ohmyzsh/blob/master/oh-my-zsh.sh))"

# 更换终端为zsh

1
chsh -s /bin/zsh

# 修复权限

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

# 安装ohmyzsh插件

1
brew install  zsh-autosuggestions zsh-syntax-highlighting

# 设置zsh全局不读取任何 git 信息

1
git config --global oh-my-zsh.hide-status 1

# 引用插件来源

1
2
3
4
5
6
7
tee >> ~/.zshrc <<'EOF'
# ==================
# 引用插件来源
# ==================
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
EOF

# 解决安装了autosuggestions插件复制粘贴出现很慢情况

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tee >> ~/.zshrc <<'EOF'
# ==================
# 解决安装了autosuggestions插件复制粘贴出现很慢情况
# ==================
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic
}
pastefinish() {
zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish
EOF

# 跳过不安全目录的验证-非必要

1
2
3
4
5
6
tee >> ~/.zshrc <<'EOF'
# ==================
# 跳过不安全目录的验证-非必要
# ==================
ZSH_DISABLE_COMPFIX="true"
EOF

# 在“PATH”设置出错的情况下修正-非必要

1
2
3
# cat >> ~/.zshrc << 'EOF'
# export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
# EOF

# 不更新brew-非必要

1
2
3
4
5
6
cat >> ~/.zshrc << 'EOF'
# ==================
# 不更新brew-非必要
# ==================
export HOMEBREW_NO_AUTO_UPDATE=true
EOF

# 如果高亮不生效-非必要

1
# export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/usr/local/share/zsh-syntax-highlighting/highlighters

# 使zsh配置生效

1
source ~/.zshrc

# 备份zshrc

1
sudo cp “.bak ~/.zshrc ~/.zshrc.bak