MacOS 终端配置记录

macOS 下 iTerm2 + oh-my-zsh + powerlevel10k 环境快速配置

安装 iTerm2

使用 iTerm2 替代 macOS 自带终端 Terminal

Home&Download:https://iterm2.com/

安装 iTerm2 主题

This is a set of color schemes for iTerm (aka iTerm2).

Github:https://github.com/mbadolato/iTerm2-Color-Schemes

Example:

安装 oh-my-zsh

Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration.

Home:https://ohmyz.sh/

Github:https://github.com/ohmyzsh/ohmyzsh

1# Install oh-my-zsh
2$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

安装 zplug 插件管理器

Github:https://github.com/zplug/zplug

1$ curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh

安装命令行工具

fzf

命令行模糊搜索

Github:https://github.com/junegunn/fzf

1brew install fzf
2# To install useful key bindings and fuzzy completion:
3$(brew --prefix)/opt/fzf/install

NOTE:put this line in the end of your zshrc, or it may not work, https://github.com/junegunn/fzf/issues/1304

1[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

新增 zpug 插件配置

添加到 ~/.zshrc 文件

 1# install zplug, plugin manager for zsh, https://github.com/zplug/zplug
 2# curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
 3# zplug configruation
 4if [[ ! -d "${ZPLUG_HOME}" ]]; then
 5  if [[ ! -d ~/.zplug ]]; then
 6    git clone https://github.com/zplug/zplug ~/.zplug
 7    # If we can't get zplug, it'll be a very sobering shell experience. To at
 8    # least complete the sourcing of this file, we'll define an always-false
 9    # returning zplug function.
10    if [[ $? != 0 ]]; then
11      function zplug() {
12        return 1
13      }
14    fi
15  fi
16  export ZPLUG_HOME=~/.zplug
17fi
18if [[ -d "${ZPLUG_HOME}" ]]; then
19  source "${ZPLUG_HOME}/init.zsh"
20fi
21zplug 'plugins/git', from:oh-my-zsh, if:'which git'
22zplug 'romkatv/powerlevel10k', use:powerlevel10k.zsh-theme
23zplug "plugins/vi-mode", from:oh-my-zsh
24zplug 'zsh-users/zsh-autosuggestions'
25zplug 'zsh-users/zsh-completions', defer:2
26zplug 'zsh-users/zsh-history-substring-search'
27zplug 'zsh-users/zsh-syntax-highlighting', defer:2
28
29if ! zplug check; then
30  zplug install
31fi
32
33zplug load

关于字体

在配置 powerlevel10k 主题时若缺少字体会提示下载,当然你也可以自行安装

Best option if on macOS and want to use Homebrew.

All fonts are available via Homebrew Cask Fonts on macOS (OS X)

1brew tap homebrew/cask-fonts
2brew install --cask font-hack-nerd-font

iTerm2 -> Preferences -> Profiles -> Text -> Non-Ascii-Font -> nerd-font -> restart iTerm2

Licensed under CC BY-NC-SA 4.0