推荐软件

vscode、chrome、ClashX、Alfred 4、iHosts、Beyond Compare、Navicat Premium、Cyberduck、Charles
image.png

显示隐藏文件

  1. // 此命令显示隐藏文件
  2. $ defaults write com.apple.finder AppleShowAllFiles -bool true
  3. // 此命令关闭显示隐藏文
  4. $ defaults write com.apple.finder AppleShowAllFiles -bool false
  5. // 命令运行之后需要重新加载Finder:快捷键option+command+esc,选中Finder,重新启动即可

安装homebrew

直接使用官方的方式安装,在国内会贼慢,推荐使用下面的方法。

  1. $ cd ~
  2. // 下载安装脚本
  3. $ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
  4. // 替换官方镜像源为清华的镜像源
  5. $ vim brew_install
  6. // #HOMEBREW_CORE_TAP = "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core".freeze
  7. // #BREW_REPO = "https://github.com/Homebrew/brew".freeze
  8. // 将上面的两个镜像源替换为下面的镜像源,如果brew_install文件没有HOMEBREW_CORE_TAP和BREW_REPO,那就直接添加在文末
  9. // HOMEBREW_CORE_TAP = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git".freeze
  10. // BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git".freeze
  11. // 安装
  12. $ ruby ./brew_install
  13. // 长期替换源
  14. // 如果你使用 bash:
  15. $ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zprofile
  16. source ~/.zprofile
  17. // 如果你使用 zsh:
  18. $ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
  19. source ~/.bash_profile

安装node

node官网,测试是否成功
image.png

安装cnpm

cnpm官网

  1. $ npm install -g cnpm --registry=https://registry.npm.taobao.org

测试是否成功
image.png

安装nrm

安装完npm和cnpm之后可以安装nrm来切换源。

  1. $ sudo cnpm i nrm -g
  2. // 使用方法
  3. $ nrm ls // 查看源
  4. $ nrm test cnpm // 测试源的下载速度
  5. $ nrm use taobao // 切换源

创建ssh key、配置git

  1. // 设置username和email
  2. $ git config --global user.name "zhangxiaozheng"
  3. $ git config --global user.email "617078920@qq.com"
  4. // 通过终端命令创建ssh key,然后一路回车
  5. $ ssh-keygen -t rsa -C "617078920@qq.com"
  6. // 查看ssh,并且复制到github等网站
  7. $ cat .ssh/id_rsa.pub

安装oh-my-zsh

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

更改zsh配置,主题样式网站

$ vim ~/.zshrc
// 推荐主题
ZSH_THEME="awesomepanda"

// 配置别名,方便使用 比如 code .
alias history="fc -il 1"
alias code="/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"
export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"

alias gf='git fetch'

alias gpu='git pull'
alias gpuo='git pull origin'
alias gpuom='git pull origin master'
alias gpuu='git pull upstream'
alias gpuum='git pull upstream master'

alias gps='git push'
alias gpso='git push origin'
alias gpsom='git push origin master'
alias gpsu='git push upstream'
alias gpsum='git push upstream master'

alias gco='git checkout'
alias gb='git branch'
alias gt='git tag'
alias gl='git log'
alias gs='git status'
alias ga='git add'
alias gci='git commit -m'
alias gm='git merge'
alias gd='git diff'
alias grb='git rebase -i'

alias gqa='git fetch upstream; git reset --hard upstream/qa'
alias gpro='git fetch upstream; git reset --hard upstream/production'

配置vscode

settings sync 信息
image.pngimage.pngimage.png

{
  "window.zoomLevel": 0,
  "window.newWindowDimensions": "maximized",
  "editor.fontFamily": "Fira Code",
  "editor.renderIndentGuides": true,
  "editor.tabSize": 2,
  "editor.fontSize": 14,
  "editor.tabCompletion": "on",
  "editor.mouseWheelZoom": true,
  "editor.renderControlCharacters": true,
  "editor.formatOnType": true,
  // 保存时格式化
  "editor.formatOnSave": true,
  "editor.formatOnPaste": true,
  "editor.wordSeparators": "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?",
  "editor.autoClosingBrackets": "always",
  "editor.smoothScrolling": true,
  "editor.minimap.enabled": false,
  "editor.wordWrapColumn": 160,
  "editor.suggestSelection": "first",
  // "editor.defaultFormatter": "esbenp.prettier-vscode",
  "git.enabled": true,
  "scss.validate": true,
  "extensions.ignoreRecommendations": true,
  "[markdown]": {
    "editor.quickSuggestions": true
  },
  "typescript.updateImportsOnFileMove.enabled": "always",
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "explorer.confirmDelete": false,
  "explorer.confirmDragAndDrop": false,
  "git.enableSmartCommit": true,
  "git.autofetch": true,
  "git.confirmSync": false,
  "breadcrumbs.enabled": true,
  "breadcrumbs.filePath": "on",
  "files.exclude": {
    "**/__init__.py": true,
    "**/.git/**": true,
    "**/.vscode/**": true,
    "**/*.pyc": true,
    "**/*hot-update.json": true,
    "**/node_modules/**": true,
    "**/venv/**": true
  },
  "files.insertFinalNewline": true,
  "files.trimTrailingWhitespace": true,
  "files.trimFinalNewlines": true,
  "files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/**": true
  },
  "javascript.preferences.quoteStyle": "single",
  "javascript.updateImportsOnFileMove.enabled": "never",
  // "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
  "javascript.implicitProjectConfig.experimentalDecorators": true,
  "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
  "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
  "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
  "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
  "html.format.wrapAttributes": "preserve-aligned",
  "html.format.wrapLineLength": 160,
  "workbench.colorTheme": "One Dark Pro",
  "workbench.activityBar.visible": true,
  "workbench.iconTheme": "vscode-icons",
  "workbench.startupEditor": "newUntitledFile",
  "files.associations": {
    "*.cjson": "jsonc",
    "*.wxss": "css",
    "*.wxs": "javascript"
  },
  "emmet.includeLanguages": {
    "wxml": "html"
  },
  "terminal.integrated.rendererType": "dom",
  "terminal.integrated.shell.osx": "zsh",
  "vsicons.dontShowNewVersionMessage": true,
  "prettier.singleQuote": true,
  "beautify.language": {
    "js": {
      "type": ["javascript", "json"],
      "filename": [".jshintrc", ".jsbeautify"]
    },
    "css": ["css", "scss"],
    "html": ["htm", "vue", "html"]
  },
  "vetur.validation.template": false,
  // "vetur.format.defaultFormatter.html": "js-beautify-html",
  "vetur.format.defaultFormatterOptions": {
    "prettier": {
      // 不加分号
      "semi": true,
      // 用单引号
      "singleQuote": true,
      // 禁止随时添加逗号
      "trailingComma": ""
    },
    "js-beautify-html": {
      "wrap_attributes": "force-expand-multiline"
    },
    "prettyhtml": {
      "printWidth": 100,
      "singleQuote": false,
      "wrapAttributes": false,
      "sortAttributes": false
    }
  }
}

mac基础设置

image.png
image.pngimage.pngimage.png