MacBook重装记录


重装电脑

shell变更

MacOS从10.15Catalina开始,终端由bash改成了zsh。(mac的终端支持6种shell,之前默认使用bash,目前默认为zsh,若不适应,可以将默认改回bash)

vim .bash_profile
source .bash_profile
改为
vim .zprofile
source .zprofile

修改机器名

sudo scutil --set HostName 新的主机名

安装Command Line Tools

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

会弹出提示确认是否安装,根据提示安装即可。

配置终端的样式

vim .zprofile

增加如下内容:
export LS_OPTIONS='--color=auto' # 如果没有指定,则自动选择颜色
export CLICOLOR='Yes' #是否输出颜色
export LSCOLORS='CxfxcxdxbxegedabagGxGx' #指定颜色
alias ll='ls -alF'  # 增加ll别名

source .zprofile

将vim的配置文件拷贝到用户目录中

cp -r /usr/share/vim/vimrc ~/.vimrc
 
vim .vimrc
 
syntax on
" 语法高亮
 
autocmd InsertLeave * se nocul
autocmd InsertEnter * se cul
" 用浅色高亮当前行
 
set tabstop=4
" Tab键的宽度
 
set softtabstop=4
set shiftwidth=4
"  统一缩进为4
 
set number
" 显示行号
 
colorscheme pablo
" 设置颜色主题
 
set ruler
" 在编辑过程中,在右下角显示光标位置的状态行
 
set scrolloff=3
" 光标移动到buffer的顶部和底部时保持3行距离

启动终端增加个性化欢迎语

sudo vim /etc/motd

内容是:

______   _       _____           _       _   
| ___ \ | |     /  ___|         (_)     | |  
| |_/ / | |     \ `--.  ___ _ __ _ _ __ | |_ 
|  __/  | |      `--. \/ __| '__| | '_ \| __|
| |     | |____ /\__/ / (__| |  | | |_) | |_ 
\_|     \_____/ \____/ \___|_|  |_| .__/ \__|
                                  | |        
                                  |_|        

安装brew

官网给出的安装方法,由于墙的原因,一直报错443

这里使用另外的原进行安装:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

执行中选择1(中科大)

安装后,执行

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask

验证安装:

% brew -v
Homebrew 3.6.20-208-g6a8dd4f
Homebrew/homebrew-core (git revision 06288210356; last commit 2023-02-03)
Homebrew/homebrew-cask (git revision d12e37658b; last commit 2023-02-03)

安装java17

Java Downloads | Oracle 中国

设置环境变量

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=.:$JAVA_HOME/bin:$PATH

验证安装:

% java -version
java version "17.0.6" 2023-01-17 LTS
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)

安装python3.9

Download Python | Python.org

设置环境变量

export PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"

alias python="/usr/local/bin/python3"

验证安装:

% python
Python 3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:37:23) 
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

激活Typora

激活typora时,需要在设置中勾选使用国内服务器

安装nodejs

Download | Node.js (nodejs.org)

安装 oh my zsh

sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

下面是删除命令

uninstall_oh_my_zsh

安装zsh-syntax-highlighting高亮和自动补全插件

cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-autosuggestions

比较中意的主题是:( theme )

  • pygmalion
  • fino
vim ~/.zshrc

# 激活插件使之生效
plugins=(git zsh-syntax-highlighting zsh-autosuggestions)
# 应用主题
ZSH_THEME="pygmalion"

source ~/.zshrc

淘宝开源镜像

http://npm.taobao.org

Chrome历史版本下载

Download older versions of Google Chrome for Windows, Linux and Mac (slimjet.com)

ChromeDriver

chromedriver.storage.googleapis.com/index.html

关闭Chrome自动更新

rm -rf /Users/sunch/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle

删除:⁨用户⁩ ▸ ⁨laobai⁩ ▸ ⁨资源库⁩ ▸ ⁨Google⁩ ▸ ⁨GoogleSoftwareUpdate⁩中的GoogleSoftwareUpdate.bundle

Firefox延长支持版

下载 Firefox 浏览器,这里有简体中文及其他 90 多种语言版本供您选择

Firefox driver

https://github.com/mozilla/geckodriver/releases

关闭微软软件自动更新

sudo chmod -R 644 /Library/Application Support/Microsoft/EdgeUpdater
sudo rm -rf /Library/Application\ Support/Microsoft/MAU2.0/Microsoft\ AutoUpdate.app
sudo rm -rf /Library/LaunchAgents/com.microsoft.update.agent.plist
sudo rm -rf /Library/LaunchDaemons/com.microsoft.autoupdate.helper.plist

文章作者: 老百
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 老百 !
 上一篇
Python Web UI自动化测试之PO模式 Python Web UI自动化测试之PO模式
目前提到Web UI自动化测试,最先想到的就是Selenium。Selenium支持多种浏览器、多种程序语言及多种平台,并且支持分布式,是当前最主流的Web UI测试框架。
2023-07-06
下一篇 
WordPress转Hexo to GiteePages WordPress转Hexo to GiteePages
之前的博客系统使用的是WordPress,由于疏于维护,版本插件等已出现了不兼容等状况。恰好空间到期,就借这个机会,将老旧的博客系统迁移到GiteePages。
2023-02-11
  目录