<commit_before>---
layout: post
title: "MacOS安装后做的配置"
description: ""
categories: [MacOS]
tags: [MacOS]
redirect_from:
  - /2019/06/22/
---

操作系统版本：MacOS Catalina  

# 目录  

> * [I、系统配置](#one)  
> * [II、第三方软件](#two)  

<a name="one"></a>

# I、系统配置  

## 安装`XCode`  
直接在`App Store`中搜索安装就行了，就是安装完成之后要启动一次，同意他的协议  

## 安装`XCode Command Line Tools`  
> $ xcode-select \-\-install  

## 安装`brew`  

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

[参考brew官网](https://brew.sh/index_zh-cn)  

## `zsh` + `oh-my-zsh` + `powerlevel10K` 配置 `Mac` 终端  

### 安装字体  

由于`powerlevel10K`用的是`powerline`用默认字体会有部分图标乱码的情况    

#### 下载字体  

[MesloLGS NF Regular.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Regular.ttf)  
[MesloLGS NF Bold.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Bold.ttf)  
[MesloLGS NF Italic.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Italic.ttf)  
[MesloLGS NF Bold Italic.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Bold%20Italic.ttf)    

上述字体挑一个下载就醒了

#### 安装字体  

双击 `ttf` 文件安装字体  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/1.png)  

#### 配置终端字体  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/2.png)  

#### 顺手设置终端关闭后退出  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/3.png)  

### 安装`zsh`  

#### 检查当前`shell`  

> $ echo $SHELL  

如果不是`zsh`执行下面操作，否则跳过  

#### 查看系统是否安装`zsh`  

> $ cat /etc/shells  

如果没有`/bin/zsh`就下载`zsh`如果有直接切换默认`shell`  

#### 下载`zsh`  

> $ brew install zsh  

#### 切换默认`shell`  

> $ chsh -s /bin/zsh  

### 安装`oh-my-zsh`  

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

or  

> $ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"  

[参考官网](https://ohmyz.sh)  

### 安装`zsh`帅气的主题`powerlevel10k`  

注意：安装之前请先安装并使用上述字体，否则部分内容乱码  

#### 安装`powerlevel10k`
> $ git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k  

#### 配置  
vim ~/.zshrc
~~~
ZSH_THEME="powerlevel10k/powerlevel10k"
~~~

#### 重启终端后根据自己的喜好配置  

[参考github](https://github.com/romkatv/powerlevel10k)  

### 安装`zsh`插件  

#### zsh-syntax-highlighting  
终端语法高亮

> $ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/4.png)  

#### zsh-autosuggestions  
猜想上一条同样开头的命令  

> $ git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/5.png)  

#### autojump  
自动跳转文件夹  

> brew install autojump  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/6.png)  

#### 修改配置文件  
vim ~/.zshrc    
~~~
plugins=(... autojump zsh-syntax-highlighting zsh-autosuggestions)  
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
~~~

### 终端配色  

#### 下载`coreutils`  
> $ brew install coreutils

#### 生成配色文件  
> $ gdircolors --print-database > ~/.dir_colors

#### 添加配色  
> $ vim ~/.zshrc
添加下面配置  
~~~
PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
alias ls='ls --show-control-chars --color=auto'
eval `gdircolors -b $HOME/.dir_colors`
~~~

### vim配色  

> $ vim ~/.vimrc  
添加下面配置
~~~
colorscheme desert
syntax on
~~~
<commit_msg>fix: 修改格式<commit_after>---
layout: post
title: "MacOS安装后做的配置"
description: ""
categories: [MacOS]
tags: [MacOS]
redirect_from:
  - /2019/06/22/
---

操作系统版本：MacOS Catalina  

# 目录  

> * [I、系统配置](#one)  
> * [II、第三方软件](#two)  

<a name="one"></a>

# I、系统配置  

## 安装`XCode`  
直接在`App Store`中搜索安装就行了，就是安装完成之后要启动一次，同意他的协议  

## 安装`XCode Command Line Tools`  
> $ xcode-select \-\-install  

## 安装`brew`  

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

[参考brew官网](https://brew.sh/index_zh-cn)  

## `zsh` + `oh-my-zsh` + `powerlevel10K` 配置 `Mac` 终端  

### 安装字体  

由于`powerlevel10K`用的是`powerline`用默认字体会有部分图标乱码的情况    

#### 1.下载字体  

[MesloLGS NF Regular.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Regular.ttf)  
[MesloLGS NF Bold.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Bold.ttf)  
[MesloLGS NF Italic.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Italic.ttf)  
[MesloLGS NF Bold Italic.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Bold%20Italic.ttf)    

上述字体挑一个下载就醒了

#### 2.安装字体  

双击 `ttf` 文件安装字体  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/1.png)  

#### 3.配置终端字体  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/2.png)  

#### 4.顺手设置终端关闭后退出  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/3.png)  

### 安装`zsh`  

#### 1.检查当前`shell`  

> $ echo $SHELL  

如果不是`zsh`执行下面操作，否则跳过  

#### 2.查看系统是否安装`zsh`  

> $ cat /etc/shells  

如果没有`/bin/zsh`就下载`zsh`如果有直接切换默认`shell`  

#### 3.下载`zsh`  

> $ brew install zsh  

#### 4.切换默认`shell`  

> $ chsh -s /bin/zsh  

### 安装`oh-my-zsh`  

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

or  

> $ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"  

[参考官网](https://ohmyz.sh)  

### 安装`zsh`帅气的主题`powerlevel10k`  

注意：安装之前请先安装并使用上述字体，否则部分内容乱码  

#### 1.安装`powerlevel10k`
> $ git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k  

#### 2.配置  
vim ~/.zshrc
~~~
ZSH_THEME="powerlevel10k/powerlevel10k"
~~~

#### 3.重启终端后根据自己的喜好配置  

[参考github](https://github.com/romkatv/powerlevel10k)  

### 安装`zsh`插件  

#### 1.zsh-syntax-highlighting  
终端语法高亮

> $ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/4.png)  

#### 2.zsh-autosuggestions  
猜想上一条同样开头的命令  

> $ git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/5.png)  

#### 3.autojump  
自动跳转文件夹  

> brew install autojump  

![file](https://github.com/xuzheyang/xuzheyang.github.io/raw/master/_pic/2019-06-22/6.png)  

#### 4.修改配置文件  
vim ~/.zshrc    
~~~
plugins=(... autojump zsh-syntax-highlighting zsh-autosuggestions)  
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
~~~

### 终端配色  

#### 1.下载`coreutils`  
> $ brew install coreutils

#### 2.生成配色文件  
> $ gdircolors --print-database > ~/.dir_colors

#### 3.添加配色  
> $ vim ~/.zshrc
添加下面配置  
~~~
PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
alias ls='ls --show-control-chars --color=auto'
eval `gdircolors -b $HOME/.dir_colors`
~~~

### vim配色  

> $ vim ~/.vimrc  
添加下面配置
~~~
colorscheme desert
syntax on
~~~

{'fraction_non_alphanumeric': 0.1973931738779898, 'fraction_numerical': 0.02875571083042193, 'mean_word_length': 3.646067415730337, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, 'https://': 36, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3944116', 'n_tokens_mistral': 3914, 'n_tokens_neox': 3863, 'n_words': 349}