macos 基本操作

5/26/2020 MacOS

# Finder

macos 在应用使用弹出式的文件选择器时选中被macos隐藏的目录,比如 /tmp/

在窗口中使用 cmd + shift + g 即可

# brew

macos 上的包管理工具,类似linux的yum和apt

# 插件

  • 特殊命令高亮
brew install zsh-syntax-highlighting

cat >>~/.zshrc<<EOF
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
EOF

source ~/.zshrc
1
2
3
4
5
6
7

**注:**如果高亮不生效,在 ~/.zshrcplugins 配置追加 zsh-syntax-highlighting 即可

  • 自动建议填充
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
1

编辑 ~/.zshrc , 在 plugins 中追加zsh-autosuggestions

# 更换源地址

  • 中科大
cd $(brew --repo)
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git

cd $(brew --repo)/Library/Taps/homebrew/homebrew-core
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
1
2
3
4
5
6
7
  • 清华
cd $(brew --repo)
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git

cd $(brew --repo)/Library/Taps/homebrew/homebrew-core
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
1
2
3
4
5
6
7
  • 恢复缺省地址
cd $(brew --repo)
git remote set-url origin https://github.com/Homebrew/brew.git

cd $(brew --repo)/Library/Taps/homebrew/homebrew-core
git remote set-url origin https://github.com/Homebrew/homebrew-core
1
2
3
4
5

# 显示缓存目录

brew --cache
1

# 为应用程序单独设置语言

defaults write com.apple.iWork.Pages AppleLanguages '("zh-Hans")'
1

# Macos 实时显示按键

brew cask install keycastr
1

# MacOS 10.15 文件已损坏

xattr -r -d com.apple.quarantine
1

# SIP

# 查看SIP状态

csrutil status
1

# 关闭SIP

重启 Command + R 进入恢复模式

csrutil disable
1

# 开启 SIP

csrutil enable
1

# 解决 无法打开应用,应该移到废纸篓

sudo spctl --master-disable
1
Last Updated: 2/1/2023, 7:54:17 AM