开发环境配置
约 710 字大约 2 分钟
macconfig
2024-08-12
1. HomeBrew
踩坑:推荐中科院的源
1、安装地址:https://zhuanlan.zhihu.com/p/111014448
2、换源地址:https://www.zhihu.com/question/31360766/answer/749386652
# 替换 Homebrew
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 替换 Homebrew Core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 替换 Homebrew Cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# 替换 Homebrew-bottles
# 对于 bash 用户:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 对于 zsh 用户:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc2. 终端
2.1. iTerm 2
2.2. iTerm 2 插件
2.2.1. tree 命令行打印目录树
# 安装
brew install tree
# 使用
# 我们要在目录遍历时使用 -L 参数指定遍历层级
tree -L 2 # 遍历两级目录2.2.2. autojump 快捷目录跳转
# 安装
brew install autojump
# 在 .zshrc 中添加插件
vim ~/.zshrc #
# 找到 plugins 并添加 autojump 插件
plugins = ( git autojump )
# 重启 zsh
source ~/.zshrc2.2.3. zsh-syntax-highlighting 命令行高亮
# 进入插件目录
cd ~/.oh-my-zsh/custom/plugins/
# 下载插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# 找到 plugins 并添加 zsh-syntax-highlighting 插件
plugins = ( git autojump zsh-syntax-highlighting )
# 重启 zsh
source ~/.zshrc2.2.4. zsh-autosuggestions 命令记忆提示
# 进入插件目录
cd ~/.oh-my-zsh/custom/plugins/
# 下载插件
git clone https://github.com/zsh-users/zsh-autosuggestions
# 找到 plugins 并添加 zsh-autosuggestions 插件
plugins = ( git autojump zsh-syntax-highlighting zsh-autosuggestions )
# 重启 zsh
source ~/.zshrc2.3. 其他终端
- Termora 开源的终端模拟器,可以当作 SSH 客户端使用,支持中文。
3. 配置 SSL 证书
使用 mkcert 工具生成 ssl 证书
brew install mkcert
brew install nss # 如果使用 Firefox
mkcert -install
mkcert "*.rain.com" localhost 127.0.0.1 0.0.0.0配置到 nginx
server {
listen 443 ssl;
server_name www.rain.com;
ssl_certificate /Users/nowcoder/rain/certs/_wildcard.rain.com+3.pem;
ssl_certificate_key /Users/nowcoder/rain/certs/_wildcard.rain.com+3-key.pem;
client_max_body_size 20m;
location / {
proxy_pass http://localhost:6666;
}
}4. Chrome Plugin
- octotree GitHub 目录插件 GitHub | 官网 GitHub code tree
- 沙拉查词-聚合词典划词翻译
- Vue.js devtools
- AdBlock — 最佳广告拦截工具
- Infinity 新标签页 (Pro)
- Tampermonkey 脚本
5. ttyd - Share your terminal over the web
这个命令行工具可以在浏览器里面,打开本机的终端窗口,让用户在浏览器执行终端命令。
brew install ttyd
ttyd -W zsh # 打开 zsh 终端6. 修改 Mac 配置
sudo lsof -i :9000 # 查看端口号进程
sudo kill -9 PID # 杀掉对应PID的进程
# 修改启动台图标排布
defaults write com.apple.dock springboard-rows -int 7
defaults write com.apple.dock springboard-columns -int 6
defaults write com.apple.dock ResetLaunchPad -bool TRUE;killall Dock
# 禁用或启用自动生成 禁止.DS_store生成:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
defaults delete com.apple.desktopservices DSDontWriteNetworkStores # 恢复默认
# Mac 访达 (Finder) 显示隐藏文件和文件夹的方法:
defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder7. 简单美化 vim
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
执行下载下来的文件
~/.vim_runtime/install_basic_vimrc.sh
得到安装成功的提示,再用vim打开.zshrc文件,会发现注释和非注释是用不同的颜色标识区分的。
