主题
终端
Zsh
配置文件
- 路径:
~/.zshrc- 不存在时创建:
touch ~/.zshrc- 修改后重新加载:
source ~/.zshrc
Oh My Zsh
安装前先备份或确认 ~/.zshrc 配置,避免被覆盖。
bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"主题
Powerlevel10k:
bash
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k插件
语法高亮:
bash
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting安装后仍需在 ~/.zshrc 的 plugins 中启用:
bash
plugins=(
git
zsh-syntax-highlighting
)使用
- 输入部分命令或路径后按
Tab:使用 Zsh 原生命令补全。 - 有效命令、路径与错误输入的颜色差异:由语法高亮提供。
配置代理
由于有 echo,需要在 Powerlevel10k 之前配置输出,否则会警告。
bash
# ====== Proxy Start ======
proxy_on() {
export http_url="http://127.0.0.1:7897"
export socks5_url="socks5://127.0.0.1:7897"
export http_proxy="$http_url"
export https_proxy="$http_url"
export HTTP_PROXY="$http_url"
export HTTPS_PROXY="$http_url"
export ALL_PROXY="$socks5_url"
export no_proxy_urls="localhost,127.0.0.1,::1,0.0.0.0,.local,host.docker.internal,gateway.docker.internal,docker.for.mac.localhost"
export no_proxy="$no_proxy_urls"
export NO_PROXY="$no_proxy_urls"
echo "终端代理已开启"
}
proxy_off() {
unset http_url socks5_url
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY
unset no_proxy_urls no_proxy NO_PROXY
echo "终端代理已关闭"
}
# 每次启动终端时自动开启代理
proxy_on
# ====== Proxy End ======升级 bash
macOS 默认的 bash 版本为 3.x,建议升级到最新版本。
bash
brew install bash后续需要通过 bash 安装软件时,通过 /opt/homebrew/bin/bash 执行安装命令。
