Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac 系统初始化记录 #60

Open
zhangxiang958 opened this issue Dec 30, 2020 · 1 comment
Open

Mac 系统初始化记录 #60

zhangxiang958 opened this issue Dec 30, 2020 · 1 comment
Labels

Comments

@zhangxiang958
Copy link
Owner

zhangxiang958 commented Dec 30, 2020

很多时候因为个人原因或者工作需要,经常需要初始化一台全新的 Mac 电脑,并且 Mac 迁移助手不是特别管用的情况下(比如自己只有这一台 MacBook 在用,不太可能等好几个小时的迁移),所以这里把拿到一台全新的 Mac 电脑初始化的步骤记录下来,方便自己以后可以迅速地配置出一台符合自己日常编程习惯的电脑。文章章节的顺序就是代表步骤顺序

修改电脑配置

触控板

点击左上角的标志,找到触控板配置
image
勾选「辅助点按」,取消「用力点按」,然后找到「更多手势」,将「在页面之间轻扫」改为「双指左右滚动」。

程序坞

image
勾选下面选项
image

安装电脑必备软件

必备(推荐先安装此部分的软件)

  • chrome (打开 safari 浏览器,找到 chrome 下载)

效率

  • alfred3
  • notions
  • typora
  • office365
  • 滴答清单

社交

  • QQ
  • Wechat
  • WeCom(企业微信)
  • Tencent Meeting

开发

  • vscode
  • goland
  • navicat(mysql 可视化)
  • datagrip(sql IDE)
  • rdm(redis 可视化)
  • docker
  • postman(接口调试)
  • wireshark(抓包)
  • switchhosts
  • iterm

日常

  • QQ 音乐
  • Sketch
  • PhotoShop CC
  • polarr

初始化系统

安装 homebrew

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

或者

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

觉得慢的话就用国内的源

/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"

hawtim/hawtim.github.io#10
https://rumosky.com/archives/517/

安装 zsh & ohmyzsh

Mac 系统自带 zsh

// 先安装 wget
brew install wget

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

配置 ohmyzsh

查看目前所有的主题

ls ~/.oh-my-zsh/themes

修改 zsh 主题 & 修改终端颜色

vim ~/.zshrc

把 「ZSH_THEME」值改为 "murilasso",然后退出

source ~/.zshrc

修改终端(iTerm2)颜色,需要下载

cd ~/Document && mkdir openSources
git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git

image
点开「Color preset」按钮,里面有个 import,点击之后,打开下载的 Schemes 文件夹,按照下面步骤:

Click on the schemes folder
Select the .itermcolors profiles you would like to import
Click on Color Presets and choose a color scheme

然后选自己喜欢的颜色就好了,之前选的是 「Broadcast」

iterm 效率设置

image

新建「文稿」中的文件夹

cd ~/Document
mkdir XXX

放置对应的项目,文件,文档等。

SSH 设置(记得将现有在使用的服务器信息都设置过来)

服务器免密登录,比如你是腾讯云的服务器,那么就先生成密钥(-f 是指定文件名)

ssh-keygen -t rsa -C "[email protected]" -f "tenentCloud"

然后把公钥内容复制到服务器的 ~/.ssh/authorized_keys

cat tencentCloud.pub

然后配置下面的快捷登陆

SSH 快捷登陆

vim ~/.ssh/config

某个配置项

Host tencentCloud
HostName 127.0.0.1
Port 8888
User root
#密钥
IdentityFile ~/.ssh/tencentCloud

然后就可以直接 ssh tencentCloud 登陆服务器了

github 配置

生成密钥

ssh-keygen -t rsa -C "[email protected]" -f "[email protected]"

将公钥复制到 github 的 setting 里面保存起来。

公司内私有代码仓库配置

这里就不放步骤了,但是要记得配置就好了

设置快捷命令

alias code="open -a \"Visual Studio Code\""
alias jump="ssh ${username} -p ${port}"

初始化开发配置

安装 Node 环境 & 配置 NPM

node 直接去官网下载对应的 pkg 然后安装就好了。链接:https://nodejs.org/en/download/
现在 node 基本都内置 npm 了,下载下来就能用,如果你的公司内部对应私有部署的 xnpm,那么就配置:

vim ~/.zshrc
alias xnpm="npm --registry=${registryURL} --registryweb=${registryWeb} --cache=$HOME/.xnpm/.cache --userconfig=$HOME/.xnpmrc"

安装 Whistle & 转移 Whistle 抓包配置

npm i -g whistle

先导出
image
然后导入导出的 txt 文件即可

安装 Golang 环境

使用 brew 来安装,先用 search 命令来看下有什么版本

brew search go

然后使用 install 命令下载

brew install [email protected]

这时候命令行输入 go 还不能用,还需要执行一下:

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

http://totzyuta.github.io/blog/2015/06/21/installing-go-by-homebrew-on-mac-os-x/

vscode

初始化

安装插件:

  • Better Comments
  • ESLint
  • Go
  • GitLens
  • indent-rainbow
  • code spell checker
  • remote - ssh(远程开发)
  • vscode-drawio
  • leetcode
  • version lens

配置

字体:Manaco,theme:abyss
image

 {
        // 显示 tab
 	"editor.renderControlCharacters": true,
       // 显示空格
 	"editor.renderWhitespace": "all"
 }

golang 开发配置

image
docstool 设置为 gogetdoc,然后 vscode 会提示让你下载 godoc

go get -u -v github.com/zmb3/gogetdoc

image
设置使用 language server,下载 gopls,如果长时间安装不上,那么就按照这个 guide:https://github.com/golang/tools/blob/master/gopls/doc/user.md

配置 eslint

# in setting.json

  "eslint.alwaysShowStatus": true,
  "eslint.validate": [
    "javascript",
    "typescript"
  ]

需要在 setting.json 加上这些配置,然后根据你的 eslint 配置文件,安装对应的 eslint npm 包,需要全局安装下 eslint

初始化 Git 配置

区分清楚 Github 和公司内部的代码仓库提交配置

为了在同一台电脑可以同时提交 github 与内网仓库,不要设置 --global,每个仓库单独设置即可

给 Docker 提速

image

{
  ...
  "registry-mirrors": [
    "https://hub-mirror.c.163.com"
  ],
  ...
}

记录个别系统问题

M3 Pro 芯片 & 系统 Sonoma 14.1 版本

whistle 出现 node Error: EPERM: operation not permitted 错误

原因是没有获得磁盘权限,修改 iTerm 权限
image
https://stackoverflow.com/questions/69293865/node-js-mac-terminal-installing-npm

whistle 访问出现代理不通问题,检查配置是否使用 localhost 域名

因为新系统会默认给 ipv6 添加到 switch hosts 配置,如果服务没有监听 ipv6 端口就会出现代理不生效问题。

@rubickecho
Copy link

赞,受你启发我也列一份自己的初始化

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants