Macbook 设置备忘

我在 MAC 上的常用命令、软件和技巧。

常用的命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 计算Md5值
md5 aaa.file

# Base64
base64 -i a.iso -o a.iso.ba64 # 编码文件
base64 -D -i a.iso -o a.iso.ba64 # 解码文件

# 系统信息
networksetup -listallhardwareports # 查看网络设备
sysctl -n machdep | grep CPU # 查看CPU型号

# 文件转码
iconv -c -f GB2312 -t UTF-8 some.file >> new.file

# 打开文件
open -a TextEdit some_file # 指定软件打开
open -e some_file # 文本编辑器打开
open -t somefile # 默认软件打开

# 代理
export ALL_PROXY="socks5://127.0.0.1:1080" # 同时设置HTTP,HTTPS
export http_proxy="socks5://127.0.0.1:1087" # part1
export https_proxy=$http_proxy # part2
curl --socks5 10.10.20.1:1080 google.com # curl使用代理

# 清空本地DNS缓存,通常用在 dig命令能够获取到IP但是ping命令不可以的情况下
sudo killall -HUP mDNSResponder

常用的软件列表

  • brew formulae 安装
    • 语言支持: nvm (nodejs), python3, golang
    • tree: 命令行工具,打印目录结构
    • ccat: 待语法解析的 cat 命令
    • proxychains: 命令行代理: github 仓库
    • ext4fuse: 读取 ext4 文件系统
  • brew casks 安装
    • 代理工具: proxifier, shadowsocksx-ng-r
    • 编辑器: visual-studio-code, typora, hex-fiend (编辑二进制数据)
    • omni: omnifocus, omnigraffle
    • 开发工具: iterm2, jetbrains-toolbox (webstorm, goland)
    • 多媒体文件: iina (视频播放), pdf-expert, xld (音频转码), the-unarchiver (解压)
    • eudic: 欧路词典
    • balenaEtcher: 制作启动盘
    • dupeguru: 扫描重复文件
    • cheatsheet: 快捷键提示
    • keycastr: 在屏幕上展示按键(用于分享会时)
    • intel-power-gadget: 展示 CPU 的实时信息
  • appStore 安装
    • Magnet: 窗口管理
  • 其他
    • xcode-select –install (调试工具)

其他技巧

家庭共享设置过程

  • 效果
    • 在 ios: music/vedio 等 app 上播放 mac 中的音乐 / 视屏 / 照片 / 有声书 / 博客等
    • 在 appleTV 上播放上述资料
  • 要求:ios/appleTV 设备上,在对应的 app 的设置里,需要和 mac 使用同一个 appleID
  • 步骤 mac:
    • 打开 Itunes,登陆 appleID
    • Itunes 设置–sharing–勾选 “在本地网络分享资料库”
    • Itunes 菜单–home sharing–turn on
  • 步骤 ios:
    • 设置–music–家庭共享–账号(视频类似)
    • 在 music 中即可播放
  • 步骤 appleTV:
    • 设置–账号–家庭共享–账号登录
    • 在 “电脑” app 中播放 2

brew 配置国内的软件园

homebrew 需要替换四个软件源

  1. Homebrew
  2. Homebrew Core
  3. Homebrew-bottles
  4. Homebrew Cask

一下使用中科大源:

1
2
3
4
5
6
7
8
9
10
11
12
# 替换 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, 在 .bashrc中设置:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles