美化你的終端利器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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章