mac 系统工作环境
说明
工欲善其事,必先利其器。
ℹ️ 说明
- 省事方式:可借助 Mac 迁移助理 进行快速同步
- ✅:免费|推荐
- ❎:收费|了解|科学
🍀 准备工作
- ✅ Homebrew - 软件包的管理器|镜像
[!!success: 推荐]
- ❎️ Ghelper - 浏览器插件 | 极简插件
- ✅ Mihomo Party - 更易用的代理客户端
- ✅ SwitchHosts - 管理切换多个 hosts 的工具 | GitHub Hosts
- ✅ Nerd Fonts - 为开发者提供图标字体补丁
bash
$ brew bundle dump --force --file=~/Desktop/Brewfile # 生成 Brewfile
$ brew bundle install --file=~/Desktop/Brewfile # 读取 Brewfile 并安装所有依赖
Brewfile
tap "oven-sh/bun"
tap "sdkman/tap"
brew "code-server", restart_service: :changed
brew "fnm"
brew "fzf"
brew "gettext"
brew "gh"
brew "git"
brew "git-extras"
brew "gping"
brew "libgpg-error"
brew "mysql", restart_service: :changed
brew "nginx", restart_service: :changed
brew "onefetch"
brew "pinentry-mac"
brew "redis"
brew "starship"
brew "syncthing", restart_service: :changed
brew "tlrc"
brew "tree"
brew "uv"
brew "zoxide"
brew "oven-sh/bun/bun"
brew "sdkman/tap/sdkman-cli"
cask "android-platform-tools"
cask "applite"
cask "arc"
cask "browserosaurus"
cask "cursor"
cask "font-fira-code-nerd-font"
cask "font-fira-mono-nerd-font"
cask "font-lxgw-wenkai"
cask "font-monaspace"
cask "font-symbols-only-nerd-font"
cask "google-chrome"
cask "hbuilderx"
cask "hyper"
cask "intellij-idea"
cask "keycastr"
cask "loop"
cask "mihomo-party"
cask "ngrok"
cask "obsidian"
cask "raycast"
cask "screen-studio"
cask "tabby"
cask "tencent-meeting"
cask "visual-studio-code"
cask "webstorm"
常用工具下载
bash
$ brew install git
$ brew install starship
$ brew install gh
$ brew install bun
$ brew install gping
$ brew install onefetch
$ brew install fzf
$ brew install zoxide
$ brew install tlrc # 控制台命令速查表 tldr-pages
$ brew install git-extras # 命令增强扩展工具
$ brew install lazygit
$ brew install nginx
$ brew install mysql
$ brew install code-server
$ brew install syncthing
$ brew install --cask mihomo-party
$ brew install --cask applite
$ brew install --cask google-chrome
$ brew install --cask arc
$ brew install --cask visual-studio-code
$ brew install --cask cursor
$ brew install --cask webstorm
$ brew install --cask intellij-idea
$ brew install --cask hbuilderx
$ brew install --cask hyper
$ brew install --cask tabby
$ brew install --cask raycast
$ brew install --cask obsidian
$ brew install --cask ngrok
$ brew install --cask loop
$ brew install --cask cleanshot
$ brew install --cask screen-studio
$ brew install --cask switchhosts
$ brew install --cask keycastr
$ brew install --cask browserosaurus
$ brew install --cask android-studio
$ brew install --cask android-platform-tools
$ brew install --cask picgo
$ brew install --cask vmware-fusion # 免费虚拟机
$ brew install --cask font-fira-code-nerd-font
$ brew install --cask font-fira-mono-nerd-font
$ brew install --cask font-lxgw-wenkai
$ brew install --cask font-monaspace
$ brew install --cask font-maple-mono-nf-cn
$ brew install --cask font-symbols-only-nerd-font
✍🏻 终端配置
- ✅ zsh - 功能强大的 shell
bash
$ touch $HOME/.zsh/plugins
$ touch $HISTFILE
$ git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git $HOME\.zsh\plugins\fast-syntax-highlighting
$ git clone https://github.com/zsh-users/zsh-autosuggestions.git $HOME\.zsh\plugins\zsh-autosuggestions
$ git clone https://github.com/zsh-users/zsh-completions.git $HOME\.zsh\plugins\zsh-completions
.zshrc 配置文件
bash
# ~/.zshrc
export ZSH=$HOME/.zsh
export ZSH_COMPDUMP=$ZSH/cache/.zcompdump-$HOST
export HISTFILE=$ZSH/.zsh_history
export HISTSIZE=5000
export SAVEHIST=5000
setopt appendhistory
setopt incappendhistory # 实时写入,避免丢失
unsetopt sharehistory # 禁用共享,防止竞争
setopt extended_history # 记录时间戳
setopt hist_ignore_all_dups # 完全去重
setopt hist_save_no_dups # 文件去重
setopt hist_find_no_dups # 搜索去重
setopt hist_expire_dups_first # 优先删除重复项
setopt hist_ignore_space # 忽略以空格开头的命令
setopt hist_reduce_blanks # 去除多余空格
setopt hist_ignore_dups # 忽略连续重复命令
setopt hist_verify # 执行历史命令前先显示
# zsh plugins
source $ZSH/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
source $ZSH/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source $ZSH/plugins/incr/incr.plugin.zsh
fpath=($ZSH/plugins/zsh-completions/src $fpath)
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
# plugins end
export PATH=$HOME/.npm_global/bin:$PATH # 自定义 npm 全局包安装路径
# fnm
eval "$(fnm env --use-on-cd)"
# fnm end
# fzf
source <(fzf --zsh)
# fzf end
# zoxide
eval "$(zoxide init zsh --cmd cd)"
function cdl() {
local dir
dir="$(zoxide query -l | fzf --reverse --height 40% \
--preview 'ls -l {}' \
--preview-window=right:60%)" && cd "${dir}"
}
function cdd() {
local dir
dir="$(find . -type d 2>/dev/null | fzf --reverse --height 40% \
--preview 'ls -l {}' \
--preview-window=right:60%)" && cd "${dir}"
}
# zoxide end
# starship
eval "$(starship init zsh)"
export STARSHIP_CONFIG=$HOME/.config/starship/starship.toml
function set_win_title(){
echo -ne "\033]0; $(basename "$USER") \007"
}
starship_precmd_user_func="set_win_title"
precmd_functions+=(set_win_title)
# starship end
# sdkman sdk 版本管理工具
export SDKMAN_DIR=$(brew --prefix sdkman-cli)/libexec
[[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh"
# sdkman end
# uv python 版本管理工具
eval "$(uv generate-shell-completion zsh)"
eval "$(uvx --generate-shell-completion zsh)"
# uv end
# alias
alias ping="gping"
alias of="onefetch"
alias nio="ni --prefer-offline"
alias s="nr start"
alias d="nr dev"
alias b="nr build"
alias cls="clear"
alias gp='git push'
alias gl='git pull'
alias grt='cd "$(git rev-parse --show-toplevel)"'
alias gc='git branch | fzf | xargs git checkout' # 搜索 git 分支并切换
alias t='tldr' # tldr 命令
# alias end
# 添加清理历史记录的函数
function history_clean() {
# 创建临时文件
local tmp=$(mktemp)
# 使用 tail -r 反向读取历史文件,然后用 awk 处理
cat $HISTFILE | tail -r | awk '
{
if (index($0, ";") > 0) {
# 命令部分是分号后面的内容
cmd = substr($0, index($0, ";") + 1);
if (!seen[cmd]++) {
# 第一次遇到这个命令(因为文件是反向读取的,所以是最新的)
result[++count] = $0;
}
} else {
# 处理没有分号的行(可能是没有时间戳的记录)
if (!seen[$0]++) {
result[++count] = $0;
}
}
} END {
# 恢复原来的顺序
for (i = count; i > 0; i--) {
print result[i];
}
}' > $tmp
# 确保处理成功后再替换原文件
if [ -s "$tmp" ]; then
mv $tmp $HISTFILE
echo "历史记录已去重,保留了最新的命令记录"
else
echo "处理出错,历史记录未修改"
rm $tmp
fi
}
- ✅️ Hyper - 是一款跨平台的终端软件
- awesome-hyper
- 配置文件位置:
~/Library/Application Support/Hyper/.hyper.js
fontFamily: 'FiraCode Nerd Font, Input Mono, monospace'
bash
$ hyper install hyper-dracula
$ hyper install hyperborder
$ hyper install hyperpower
- ✅ Starship - 轻量、迅速、客制化的高颜值终端
bash
$ brew install starship
$ cd .config && mkdir starship && cd starship && type null>starship.toml
starship.toml 配置文件
bash
command_timeout = 10000
# 在提示符之间插入空行
add_newline = true
# 将提示符中的 '❯' 替换为 '➜'
[character]
success_symbol = '[➜](bold green)'
# 禁用 'package' 组件,将其隐藏
[package]
disabled = true
[localip]
ssh_only = false
format = '[$localipv4](bold green) '
disabled = true
[cmd_duration]
min_time = 500
format = 'underwent [$duration](bold yellow)'
disabled = true
💻️ 开发环境
bash
# 设置本地默认分支 main
$ git config --global init.defaultBranch main
# 设置文件大小写敏感
$ git config --global core.ignorecase false
# 忽略目录安全限制
$ git config --global --add safe.directory "*"
- ✅ fnm - 快速简单的 Node.js 版本管理器
bash
# fnm 支持多项目单独切换版本
$ brew install fnm
$ echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc
$ source ~/.zshrc
$ fnm ls
$ fnm ls-remote
$ fnm ls-remote | grep v20
$ fnm install --lts
$ fnm install --latest
$ fnm install 16.14.2
$ fnm install 14.16.0
$ fnm default X
$ fnm use X
$ fnm env
# 项目写入 node 版本
$ node --version > .node-version
- ✅ 自定义 npm 全局包安装位置
bash
$ mkdir -p ~/.npm_global
$ npm config set prefix ~/.npm_global
# 设置环境变量
echo "# 自定义 npm 全局包安装路径" >> ~/.zshrc
echo "export PATH=~/.npm_global/bin:$PATH" >> ~/.zshrc
echo "# end" >> ~/.zshrc
$ source ~/.zshrc
$ npm i -g @antfu/ni
💻️ 办公工具
- ✅ Raycast - 一个为 mac 设计的高效生产力工具
- ️❎️ Applite - 简化使用 Homebrew 的第三方应用程序的安装和管理
- ✅ 微信键盘
- ✅ Arc - 浏览器
- ✅ CleanMyMac X - mac 清洁应用程序 | 国内代理商
- ✅ Tabby - 跨平台终端应用程序,本地 shell、串行、SSH 和 Telnet 连接
- ✅ iShot Pro - 专业的截图贴图录屏录音 OCR 翻译取色工具
- ❎️ CleanShot X - 功能强大的屏幕捕捉工具
- ❎️ Screen Studio - 屏幕录制软件
- ✅ 右键助手专业版 - 超丰富的右键菜单
- ✅ Loop - 简化窗口管理
- ✅ Browserosaurus - 适用于 mac 多浏览器用户
- ✅ Kap - GIF 录制
- ✅ The Unarchiver - 解压工具
- ✅ IINA - 现代媒体播放器
- ✅ Obsidian - 是一款私密且灵活的写作应用程序
- ✅ Command X - 在 Finder 中剪切和粘贴文件
- ✅ KeyCastr - 一个开源的按键可视化工具
- ❎ Picture View - mac 图片浏览应用
- ✅ PicGo - 图片上传 - 管理新体验
- ✅ LocalSend - 免费、开源、跨平台,将文件分享到附近的设备
- ✅ 多邻国 - 全球数亿语言学习者的口碑选择
- ✅ 万词王 - 视频背单词学英语必备 APP
- ✅ 微信读书
- ✅ 新华字典
- ❎ Scroll Reverser - 触摸板与鼠标滚动方向独立设置
♻️ 资源平台
- ✅ macOSicons - 更换 mac 应用图标
- ✅ Dockhunt - 程序坞应用分享平台
- ✅ 麦软网 - 专业正版低价软件
- ✅ 数码荔枝 - 专注于分享最新鲜优秀的正版软件
- ❎ MacKed - 专注于 mac 软件分享与下载
- ✅ awesome-mac
- ✅ AppStorrent
- ✅ XMac
- ✅ XClient
- ✅ Digit77
- ✅ MacWK
- ✅ MacBL
- ❎ MacApp分享频道
- ✅ IDEA 破解
- ✅ 适用于苹果芯片了吗? - 应用程序指南