mac 配置iTerm2和oh-my-zsh主题

一、安装iTerms2

  • 官网下载安装
  • 通过运行以下命令将默认 shell 改为zsh
chsh -s /bin/zsh

二、安装oh-my-zsh

  • 根据官网,使用curl或者wget下载
# curl 方式
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 或 wget 方式
$ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
  • 注意:由于“不知名原因”,可能出现无法下载情况,如:installer: Failed to connect to github: Connection refused
  • 直接用git clone下载
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh

三、iTerms2换主题搭色

  • 修改主题,改用agnoster
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="robbyrussell"
ZSH_THEME="agnoster"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load

请添加图片描述

  • 使用Dark Backgrounp,修改显示颜色,Blue改成268bd2,Yellow改用b58900,参考Preferences——Profiles——colors——Color Presets——Solarized Dark配色
    mac 配置iTerm2和oh-my-zsh主题_第1张图片
    请添加图片描述

  • 隐藏用户名和主机名,vim ~/.oh-my-zsh/themes/agnoster.zsh-theme,注释if语句里面哪一行

### Prompt components
# Each component will draw itself, and hide itself if no information needs to be shown

# Context: user@hostname (who am I and where am I)
prompt_context() {
  if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    # prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
  fi
}

请添加图片描述

  • 修改字体
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh


mac 配置iTerm2和oh-my-zsh主题_第2张图片

四、安装插件

  • 安装目录跳转工具(autojump是一个命令行工具,它允许你可以直接跳转到你喜爱的目录,而不受当前所在目录的限制。意思就是可以让你更快地切换目录,而不用频繁地使用cd tab 等命令。)
brew install autojump
  • 安装自动补全插件
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-autosuggestions.git
  • 安装命令高亮插件
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
  • 加载命令配置
echo '
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
' >> ~/.zshrc

  • 在 ~/.zshrc 中修改 plugins=(git) 为,zsh-syntax-highlighting要放到最后面
plugins=(
    git
    autojump
    zsh-autosuggestions
    zsh-syntax-highlighting
)

五、参考

  • Mac M1配置iTerm2+oh-my-zsh配色&补全&高亮命令
  • oh-my-zsh安装插件autojump、zsh-autosuggestion 以及 zsh-syntax-highlighting
  • iTerm2 + oh my zsh +agnoster 打造最强Mac终端

你可能感兴趣的:(macos,iTerms,oh-my-zsh)