macOS 开发环境配置

2024/04/30

这篇文章主要记录了我的 macOS 开发环境的配置。我个人比较偏好简单的配置,因此以下配置并非一个「稳定的」开发环境配置,而是更遵循 Homebrew 的哲学,一切工具都使用最新版本。

我的绝大部分开发工具都是使用 Homebrew 进行安装,也通过它进行版本管理。但是 rust 的开发是一个特例,rust 我使用 rustup 进行环境配置,这也是主流的配置方式。

我的 .zshrc

if [ "$ALACRITTY" = "true" ]
then
  local ALA_HOME=$HOME/.config/alacritty
  local ALA_THEME=$(defaults read -g AppleInterfaceStyle 2>/dev/null || echo "Light" | tr '[:upper:]' '[:lower:]')
  theme() { ln -sf $ALA_HOME/themes/themes/$1.toml $ALA_HOME/active.toml; }
  theme github_$ALA_THEME
fi

if type brew &>/dev/null
then
  FPATH="/opt/homebrew/share/zsh/site-functions:${FPATH}"
  FPATH="/opt/homebrew/share/zsh-completions:${FPATH}"

  autoload -Uz compinit
  compinit
fi

source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh

eval "$(starship init zsh)"
eval "$(atuin init zsh --disable-up-arrow)"

alias drcom="$HOME/Develop/github.com/xqm32/drcom.sh"
alias ll="eza -l"
alias tree="eza -T"
alias python=".venv/bin/python"
alias pip="uv pip"
alias venv="uv venv"

我的 .zprofile

eval "$(/opt/homebrew/bin/brew shellenv)"
. "$HOME/.cargo/env"

export PATH="$HOME/go/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"

未完待续…