MacBook Pro 参数

  • MacBook Pro (16-inch, 2019)
  • 2.6 GHz 6-Core Intel Core i7
  • 16 GB 2667 MHz DDR4
  • 512GB SSD
  • AMD Radeon Pro 5300M 4 GB
  • macOS Monterey

    系统偏好

    Dock

  • 从码头中删除大多数应用程序

  • 自动隐藏
  • 较小的码头
  • “在码头中显示最新申请”
  • “开放应用程序的显示指标”
  • 电池 - >“显示百分比”

    显示

  • 夜览

    提示

  • 关闭除日历外的全部

    触摸板

  • 开启轻触点击

    共享

  • 修改电脑名

    • 终端修改方法:
      1. sudo scutil --set ComputerName "newname"
      2. sudo scutil --set LocalHostName "newname"
      3. sudo scutil --set HostName "newname"

      存储优化

  • 移除 Garage Band 和 音乐库 (如果不需要的话)

  • 移除 IMovie (如果不需要的话)

    更多从终端设置的配置

    ```html

    take screenshots as jpg (usually smaller size) and not png

    defaults write com.apple.screencapture type jpg

do not open previous previewed files (e.g. PDFs) when opening a new one

defaults write com.apple.Preview ApplePersistenceIgnoreState YES

show Library folder

chflags nohidden ~/Library

show hidden files

defaults write com.apple.finder AppleShowAllFiles YES

show path bar

defaults write com.apple.finder ShowPathbar -bool true

show status bar

defaults write com.apple.finder ShowStatusBar -bool true

killall Finder;

  1. <a name="uOLJF"></a>
  2. ## Git
  3. 在macOS上使用Git 用户需额外要求安装 Command Line Tools (CLT) for Xcode。
  4. <a name="j4UFu"></a>
  5. ### 安装
  6. <a name="KaM7O"></a>
  7. #### 自动安装
  8. 在终端输入
  9. ```bash
  10. git --version

如果没有安装Git,将会弹窗提示窗,根据提示安装即可。
如果有安装则显示出 git版本信息。如:

  1. git version 2.32.0 (Apple Git-132)

手动安装

在终端中输入:

  1. xcode-select --install

根据提示点击确认即可自动安装。

配置

配置全局用户名、全局邮箱作为配置信息:

  1. git config --global user.name "your_name"
  2. git config --global user.email "your_email@youremail.com"

Git默认对大小写不敏感,也就是说,将一个文件名某个字母做了大小写转换的修改Git是忽略这个改动的,导致在同步代码时候会出现错误,所以建议把Git设置成大小写敏感。

  1. git config core.ignorecase false

配置默认分支

  1. // 这里是设置为 main 以前通常默认是 master
  2. git config --global init.defaultBranch main

优化Git日志显示

  1. git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

之后查看日志使用: git lg

查看Git的配置信息

使用git config 指令查看配置信息:

  1. git config --list

oh-my-zsh

Oh My Zsh是一个令人愉快的、开源的、社区驱动的用于管理Zsh配置的框架。它捆绑了数千个有用的功能,助手,插件,主题。
官方网站:https://ohmyz.sh/

安装

从清华大学镜像源安装

  1. git clone https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
  2. cd ohmyzsh/tools
  3. REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.sh

切换已有 ohmyzsh 至镜像源

  1. git -C $ZSH remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
  2. git -C $ZSH pull

Homebrew

homebrew是macOS上的一个包管理器,仅需执行相应的命令,就能下载安装需要的软件包,可以省掉自己去下载、解压、拖拽(安装)等繁琐的步骤。

Homebrew 官方文档 https://brew.sh/

安装

这里使用 清华大学 镜像 保证使用中速度快于使用国外镜像。

首先,需要确保系统中安装了 bash、git 和 curl,对于 macOS 用户需额外要求安装 Command Line Tools (CLT) for Xcode。
接着,在终端输入以下几行命令设置环境变量:

  1. export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
  2. export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
  3. export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

最后,在终端运行以下命令以安装 Homebrew / Linuxbrew:

  1. # 从本镜像下载安装脚本并安装 Homebrew / Linuxbrew
  2. git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
  3. /bin/bash brew-install/install.sh
  4. rm -rf brew-install
  5. # 也可从 GitHub 获取官方安装脚本安装 Homebrew / Linuxbrew
  6. /bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install.sh)"

这样在首次安装的时候也可以使用镜像。更多信息请参考 Homebrew 官方安装文档。
安装成功后需将 brew 程序的相关路径加入到环境变量中:

  • 以下针对基于 Apple Silicon CPU 设备上的 macOS 系统(命令行运行 uname -m 应输出 arm64)上的 Homebrew:

    1. test -r ~/.bash_profile && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
    2. test -r ~/.zprofile && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
  • 对基于 Intel CPU 设备上的 macOS 系统(命令行运行 uname -m 应输出 x86_64)的用户可跳过本步。

    用法

    ```bash

    查询:

    brew search 软件名

安装:

brew install 软件名

卸载:

brew uninstall 软件名

更新 Homebrew:

brew update

查看 Homebrew 配置信息:

brew config

  1. <a name="VcNFc"></a>
  2. ## nodejs安装
  3. <a name="NqMDH"></a>
  4. ### nvm
  5. nodejs版本管理工具。
  6. <a name="BYoPW"></a>
  7. #### 安装 nvm
  8. ```bash
  9. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  10. # 或
  11. wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

安装完成后刷新环境:

  1. #bash:
  2. source ~/.bashrc
  3. #zsh:
  4. source ~/.zshrc
  5. #ksh:
  6. . ~/.profile

常用命令

  1. // 查看可安装的nodejs版本
  2. nvm ls-reomte
  3. // 查看已安装版本
  4. nvm ls
  5. // 安装指定版本
  6. nvm install v16.15.0
  7. // 切换nodejs版本
  8. nvm use v16.15.0
  9. // 卸载nodejs版本
  10. nvm uninstall v16.15.0
  11. // 切换nodejs默认版本
  12. nvm alias default v17.0.0

查看node目录:

  1. npm root -g
  2. npm bin -g

nrm

npm安装源管理工具。

nrm安装

  1. # 使用淘宝镜像安装nrm
  2. npm i nrm -g --registry=https://registry.npmmirror.com/

使用说明

  1. // 查看已有仓库镜像
  2. nrm ls
  3. // 设置本地使用镜像
  4. nrm use <镜像名>
  5. // 添加仓库镜像
  6. nrm add <镜像名> <仓库地址>
  7. // 删除镜像
  8. nrm remove <镜像名>

VS Code

扩展推荐:

  • Dracula Official (Theme)
  • Auto Hide (Hides Sidebar)
  • EditorConfig (Shared Config)
  • ESLint (Code Style)
  • Prettier (Code Format)
  • GitLens (Visualize Git)
  • Better Comments (Comment Highlighting)
  • Import Cost
  • Highlight Matching Tag
  • Auto Rename Tag
  • Auto Close Tag
  • Color Highlight
  • ES7+ React/Redux/React-Native snippets
  • VSCode React Refactor
  • Vscode-styled-components
  • Color Highlight
  • Color Picker
  • markdown-preview-enhanced
  • GitHub.copilot
  • powermode

    配置:

    1. {
    2. "window.zoomLevel": 1,
    3. "editor.tabSize": 2,
    4. "editor.insertSpaces": true,
    5. "editor.wordWrap": "on",
    6. "editor.trimAutoWhitespace": true,
    7. "editor.renderWhitespace": "all",
    8. "editor.codeActionsOnSave": {
    9. "source.fixAll.tslint": true,
    10. "source.fixAll.eslint": true
    11. },
    12. "editor.formatOnSave": false,
    13. "editor.fontFamily": "'Source Code Pro','Fira Code','JetBrains Mono', Dank , Mono, Menlo",
    14. "editor.fontSize": 16.0,
    15. "editor.lineHeight": 1.5,
    16. "editor.fontLigatures": true,
    17. "editor.fontWeight": "400",
    18. "editor.tokenColorCustomizations": {
    19. "textMateRules": [
    20. {
    21. "scope": [
    22. "comment"
    23. ],
    24. "settings": {
    25. "fontStyle": "italic"
    26. }
    27. },
    28. {
    29. "scope": [
    30. //following will be excluded from italics (VSCode has some defaults for italics)
    31. "constant",
    32. "storage.modifier",
    33. "storage.type",
    34. "keyword.control",
    35. "keyword.operator",
    36. "invalid",
    37. "entity.name.tag.doctype",
    38. "entity.other.attribute-name",
    39. "entity.other.attribute-name.tag.jade",
    40. "entity.other.attribute-name.tag.pug"
    41. ],
    42. "settings": {
    43. "fontStyle": "bold"
    44. }
    45. }
    46. ]
    47. },
    48. "eslint.alwaysShowStatus": true,
    49. "eslint.options": {
    50. "extensions": [
    51. ".js",
    52. ".vue"
    53. ]
    54. },
    55. "files.insertFinalNewline": true,
    56. "files.associations": {
    57. "*.vue": "vue",
    58. "*.wpy": "vue",
    59. "*.cjson": "jsonc",
    60. "*.wxss": "css",
    61. "*.wxs": "javascript",
    62. "*.wxml": "html",
    63. "*.tpl": "html",
    64. "*.swig": "html",
    65. "*.json5": "json",
    66. "*.xml": "vue",
    67. "*.art": "html"
    68. },
    69. "prettier.singleQuote": true,
    70. "prettier.semi": true,
    71. "vetur.validation.template": false,
    72. "files.exclude": {
    73. "**/.DS_Store": true,
    74. "**/.hg": true,
    75. "**/.idata": true,
    76. "**/.idea": true,
    77. "**/.svn": true,
    78. "**/CVS": true,
    79. "**/dist": false,
    80. "**/node_modules": false
    81. },
    82. "files.watcherExclude": {
    83. "**/.git/objects/**": true,
    84. "**/.git/subtree-cache/**": true,
    85. "**/node_modules/**": true,
    86. "**/tmp/**": true,
    87. "**/bower_components/**": true,
    88. "**/dist/**": true
    89. },
    90. "typescript.check.npmIsInstalled": false,
    91. "git.enableSmartCommit": true,
    92. "search.followSymlinks": true,
    93. "git.autofetch": true,
    94. "gitlens.advanced.messages": {
    95. },
    96. "files.trimTrailingWhitespace": true,
    97. "window.nativeTabs": true,
    98. "emmet.includeLanguages": {
    99. "wxml": "html"
    100. },
    101. // "minapp-vscode.disableAutoConfig": true,
    102. "extensions.ignoreRecommendations": false,
    103. "gitlens.views.repositories.files.layout": "list",
    104. "gitlens.statusBar.alignment": "left",
    105. "gitlens.mode.statusBar.alignment": "left",
    106. "breadcrumbs.enabled": true,
    107. "[html]": {
    108. "editor.defaultFormatter": "esbenp.prettier-vscode"
    109. },
    110. "[javascript]": {
    111. "editor.defaultFormatter": "vscode.typescript-language-features"
    112. },
    113. "[json]": {
    114. "editor.defaultFormatter": "vscode.json-language-features"
    115. },
    116. "[css]": {
    117. "editor.defaultFormatter": "esbenp.prettier-vscode"
    118. },
    119. "[php]": {
    120. "editor.defaultFormatter": "kokororin.vscode-phpfmt"
    121. },
    122. "[less]": {
    123. "editor.defaultFormatter": "esbenp.prettier-vscode"
    124. },
    125. // "terminal.integrated.shell.osx": "zsh",
    126. // "terminal.integrated.fontFamily": "'DejaVu Sans Mono for powerline', 'Meslo LG S DZ for powerline', monospace",
    127. "terminal.integrated.fontSize": 15,
    128. "terminal.integrated.lineHeight": 1.2,
    129. "workbench.settings.editor": "json",
    130. "todo-tree.highlights.enabled": false,
    131. "[typescript]": {
    132. "editor.defaultFormatter": "vscode.typescript-language-features"
    133. },
    134. "[vue]": {
    135. "editor.defaultFormatter": "octref.vetur"
    136. },
    137. "[typescriptreact]": {
    138. "editor.defaultFormatter": "esbenp.prettier-vscode"
    139. },
    140. "[scss]": {
    141. "editor.defaultFormatter": "esbenp.prettier-vscode"
    142. },
    143. // powermode
    144. "powermode.enabled": true, // 启用效果
    145. "powermode.presets": "particles", // 是否启用震动
    146. "[javascriptreact]": {
    147. "editor.defaultFormatter": "esbenp.prettier-vscode" // 默认格式化器
    148. },
    149. "[markdown]": {
    150. // "editor.defaultFormatter": "yzhang.markdown-all-in-one",
    151. },
    152. "[jsonc]": {
    153. "editor.defaultFormatter": "vscode.json-language-features"
    154. },
    155. "workbench.iconTheme": "file-icons",
    156. "terminal.integrated.allowChords": false,
    157. "terminal.integrated.sendKeybindingsToShell": true,
    158. "markdown-preview-enhanced.previewTheme": "vue.css",
    159. "diffEditor.ignoreTrimWhitespace": false,
    160. "[nginx]": {
    161. "editor.defaultFormatter": "raynigon.nginx-formatter"
    162. },
    163. "editor.inlineSuggest.enabled": true,
    164. "gitlens.views.repositories.showBranchComparison": "branch",
    165. "gitlens.menus": {
    166. "editor": {
    167. "blame": false,
    168. "clipboard": true,
    169. "compare": true,
    170. "history": false,
    171. "remote": false
    172. },
    173. "editorTab": {
    174. "clipboard": true,
    175. "compare": true,
    176. "history": true,
    177. "remote": true
    178. },
    179. "explorer": {
    180. "clipboard": true,
    181. "compare": true,
    182. "history": true,
    183. "remote": true
    184. },
    185. "scm": {
    186. "authors": true
    187. },
    188. "scmGroupInline": {
    189. "stash": true
    190. },
    191. "scmGroup": {
    192. "compare": true,
    193. "openClose": true,
    194. "stash": true
    195. },
    196. "scmItem": {
    197. "clipboard": true,
    198. "compare": true,
    199. "history": true,
    200. "remote": false,
    201. "stash": true
    202. }
    203. },
    204. "gitlens.views.commits.files.layout": "list",
    205. "bracketPairColorizer.depreciation-notice": false,
    206. "github.copilot.enable": {
    207. "*": true,
    208. "yaml": false,
    209. "plaintext": false,
    210. "markdown": true
    211. },
    212. "redhat.telemetry.enabled": true,
    213. "powermode.shake.enabled": false,
    214. "editor.minimap.enabled": false,
    215. "editor.renderControlCharacters": false,
    216. "gitlens.defaultDateFormat": null,
    217. "git.confirmSync": false,
    218. "workbench.colorTheme": "Dracula",
    219. }