lxq.link
postscategoriestoolsabout

macOS的配置和使用

Homebrew (Package Manager For macOS)

Install

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

更换默认源

Homebrew的更新源由三部分组成:本体(brew.git)、核心(homebrew-core.git)以及二进制预编译包(homebrew-bottles)。 默认官方的更新源都是存放在GitHub上的,所以我们会倾向于选择国内提供的更新源,可以提高访问速度。(本文中默认更换的是中国科大的软件源)

# 替换brew.git:
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

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

# 增加homebrew-bottles环境变量:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 更新软件源:
$ brew update

# 更新现有软件
$ brew upgrade

# 清理旧有的软件包
$ brew cleanup

重置回默认源

# 重置brew.git:
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git

# 重置homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git

# 删除环境变量HOMEBREW_BOTTLE_DOMAIN

# 更新软件源
$ brew update

Iterm2 Terminal

iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with macOS 10.14 or newer. iTerm2 brings the terminal into the modern age with features you never knew you always wanted.

Oh My Zsh

Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.

# Install by curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

GIT

brew install git

设置

在文件夹顶部显示完整文件路径

$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES

.DS_Store

.DS_Store是Mac OS保存文件夹的自定义属性的隐藏文件,如文件的图标位置或背景色,相当于Windows的desktop.ini。

禁止.DS_store生成(重启Mac即可生效):

$ defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE

恢复.DS_store生成(重启Mac即可生效):

$ defaults delete com.apple.desktopservices DSDontWriteNetworkStores

删除所有.DS_Store文件

$ sudo find / -name ".DS_Store" -depth -exec rm {} \

重置 Launchpad

defaults write com.apple.dock ResetLaunchPad -bool true
killall Dock

快捷键 去苹果官网查看更多

  • 显示隐藏文件夹 : Command + Shift + .
  • 打开多个终端(需要保持焦点在终端上)
  • 打开新的终端页面 : Command + N
  • 在当前终端内打开新的Tap : Command + T
  • 文件的剪切复制: mac 系统文件(文件夹)没有(Cmd + X, Cmd + V)快捷键,如果想剪切复制源文件,继续使用复制快捷键(Cmd + C),在目标文件夹使用 Cmd + Opt + V, 源文件就会被剪切
2019-09-30