美化你的终端利器Iterm2

Iterm2是特别好用的一款终端,支持自定义字体和高亮,让日常开发,充满愉悦。

安装iterm2(mac版)

brew tap caskroom/cask
brew cask install iterm2 # 或者去网站下载安装包

偏好配置

设置256颜色

# report terminal type: xterm-256color
iTerm2 -> Preferences -> Profiles -> Terminal

配置高颜值颜色

mkdir ~/.iterm2 && cd ~/.iterm2
git clone https://github.com/mbadolato/iTerm2-Color-Schemes

# 导入颜色 import...
iTerm2 -> Preferences -> Profiles -> colors
# 选择iTerm2-Color-Schemes下的schemes目录下所有文件

安装字体

安装开源字体

brew tap caskroom/fonts
brew cask install font-hack-nerd-font
# 若安装失败,则可能是被墙了,需要加代理

配置iterm2

# iTerm2 -> Preferences -> Profiles -> Text -> Font下
# 勾选 Use a different font for non-ASCII text
# 配置字体为 Hack Nerd font

安装zsh

brew install zsh
# 默认的shell是bash,需要改为zsh
sudo sh -c "echo $(which zsh) >> /etc/shells"
chsh -s $(which zsh)
# 安装oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

配置主题

# 下载高颜值主题
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
# 配置 ZSH_THEME="powerlevel9k/powerlevel9k"
vim ~/.zshrc
# 应用生效
source ~/.zshrc

其他配置

vim ~/.zshrc

POWERLEVEL9K_MODE="nerdfont-complete"
# Customise the Powerlevel9k prompts
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh dir vcs newline status)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true

插件推荐

autojump

# 安装插件
brew install autojump
# 配置 .zshrc
vim ~/.zshrc
# 添加 plugins = (git autojump)
# 并在.zshrc文件中添加如下一行
# [[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
# 应用生效
source ~/.zshrc

zsh-autosuggestions

# 安装插件
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
# 配置 .zshrc
vim ~/.zshrc
# 添加 plugins = (git zsh-autosuggestions)
# 应用生效
source ~/.zshrc

zsh-syntax-highlighting

# 安装插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 配置 .zshrc
vim ~/.zshrc
# 添加 plugins = (git zsh-syntax-highlighting)
# 应用生效
source ~/.zshrc

效果图

Iterm2界面

常用快捷键

# 移动到行首
Ctrl + a

# 移动到行末
Ctrl + e

# 删除到行首
Ctrl + u

# 删除到行末
Ctrl + k

# 上一条命令
Ctrl + p

# 历史命令
Ctrl + r

猜你喜欢

转载自www.cnblogs.com/CocoML/p/12727132.html