讓你的命令行告別黑白饺蚊,進入彩色時代!
1. iterm2 安裝
下載安裝:https://www.iterm2.com/downloads.html
或使用 Homebrew命令安裝:
brew cask install iterm2
2. 配置 iTerm2 主題
iTerm2 最常用的主題是 Solarized Dark theme悬嗓,下載地址
http://ethanschoonover.com/solarized
下載的是壓縮文件污呼,你先解壓一下,然后打開 iTerm2包竹,按Command + ,鍵燕酷,打開 Preferences 配置界面,然后Profiles -> Colors -> Color Presets -> Import周瞎,選擇剛才解壓的solarized -> iterm2-colors-solarized -> Solarized Dark.itermcolors文件苗缩,導(dǎo)入成功,最后選擇 Solarized Dark 主題堰氓。
3. 配置 Oh My Zsh
Oh My Zsh 是對主題的進一步擴展挤渐,地址:https://github.com/robbyrussell/oh-my-zsh
一鍵安裝命令:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
安裝好之后,需要把 Zsh 設(shè)置為當前用戶的默認 Shell(這樣新建標簽的時候才會使用 Zsh)運行命令:
chsh -s /bin/zsh
執(zhí)行成功后双絮,查看當前shell
$ echo $SHELL
/bin/zsh
我們編輯vi ~/.zshrc文件浴麻,將主題配置修改為ZSH_THEME="agnoster"
4. 配置 Meslo 字體
使用上面的主題得问,需要 Meslo 字體支持,否則會出現(xiàn)亂碼软免,字體下載地址:Meslo LG M Regular for Powerline.ttf(執(zhí)行下面命令下載并安裝)
git clone git@github.com:powerline/fonts.git
# 安裝
./fonts/install.sh
然后打開 iTerm2宫纬,按Command + ,鍵,打開 Preferences 配置界面膏萧,然后Profiles -> Text -> Font -> Chanage Font漓骚,選擇 Meslo LG M Regular for Powerline 字體。
5. 安裝高亮插件
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
編輯vi ~/.zshrc文件
plugins=(
git
zsh-syntax-highlighting
)
# 刷新mac本來的配置
source ~/.bash_profile
# 刷新別名
source ~/.bashrc
# 必須保證高亮插件在最后
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
最后榛泛,刷新配置看看效果:source ~/.zshrc
6. 快捷鍵配置
-
alt+空格鍵:快捷鍵快速呼出和隱藏
- iterm2常用快捷鍵
alt+空格鍵 :快速喚出
command + ; :查看歷史命令同history命令
command + shift + h :查看剪貼板歷史
ctrl + u 清除光標前的字符
ctrl + k 清除光標后的字符
ctrl + w 清除光標前的一個word單詞
ctrl + a 光標移到行首
ctrl + e 光標移到行尾
command+d :垂直分割蝌蹂;
command+shift+d :水平分割
command+enter :全屏切換
command + t : 新建標簽
command + w : 關(guān)閉標簽
command + 數(shù)字 或 command + 左右方向鍵 : 切換標簽
command + f : 查找