Mac启用item2 + zsh + oh-my-zsh

安装item2

  • 进入 https://www.iterm2.com
  • 选择版本下载

修改 shell 为 zsh

  • 进入 item2
  • 查看是否有zsh,没有需要安装zsh
cat /etc/shells

执行结果:
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
  • 修改终端为zsh
chsh -s /bin/zsh
1
  • 重启查看配置是否生效:
echo $SHELL

执行结果:
/bin/zsh
1
2
3
4

安装 oh-my-zsh

  • github: https://github.com/robbyrussell/oh-my-zsh
  • 安装
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
1

修改 oh-my-zsh 主题

  • 修改主题为ys
vi ~.zshrc

ZSH_THEME="ys"
1
2
3

安装插件

  • zsh-autosuggestions 自动补全历史输入过的命令
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

启用
vi ~.zshrc

plugins=(
  ...
  zsh-autosuggestions
)
1
2
3
4
5
6
7
8
9
  • syntax-highlighting 语法高亮插件

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

启用
vi ~.zshrc

plugins=(
  ...
  zsh-syntax-highlighting
)
1
2
3
4
5
6
7
8
9
10
  • autojump 目录跳转
brew install autojump

启用
vi ~.zshrc

plugins=(
  ...
  autojump
)

[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh

1
2
3
4
5
6
7
8
9
10
11
12
Last Updated: 2/19/2019, 7:53:25 PM