之前一直使用的是mac自帶的終端,由於之前命令操作較少,也就無所謂了。但是現在隨着命令行操作的頻繁,原有的終端開發效率太低,偶然發現了iTerm2,發現功能很強大也非常好用,下面總結一下安裝步驟和相應的配置。
安裝iTerm2
下載地址:https://www.iterm2.com/downlo...
也可以通過Homebrew來安裝
$ brew cask install iterm2
配置iTerm2主題
iTerm2 最常用的主題是 Solarized Dark theme
下載地址:http://ethanschoonover.com/so...
下載的是壓縮文件,解壓後,打開iTerm2,按Command+,
鍵,打開Preferences配置頁面,然後Profiles -> Colors -> Color
Presets -> Import,選擇剛解壓的壓縮文件solarized->iterm2-colors-solarized->Solarized Dark.itermcolors
文件,導
入成功,最後選擇Solarized Dark 主題,就可以了。
配置 Oh My Zsh
Oh My Zsh 是對主題的進一步擴展,地址:https://github.com/robbyrusse...
一鍵安裝:
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
安裝好之後,需要把 Zsh 設置爲當前用戶的默認 Shell(這樣新建標籤的時候纔會使用 Zsh):
$ chsh -s /bin/zsh
然後,我們編輯vim ~/.zshrc
文件,將主題配置修改爲ZSH_THEME="agnoster"
agnoster
是比較常用的 zsh 主題之一,你可以挑選你喜歡的主題,zsh 主題列表:https://github.com/robbyrusse...
配置後,效果如下:
配置 Meslo 字體
使用上面的主題,需要 Meslo 字體支持,要不然會出現亂碼的情況,字體下載地址:Meslo LG M Regular for Powerline.ttf
下載好之後,直接在 Mac OS 中安裝即可。
然後打開 iTerm2,按Command + ,
鍵,打開 Preferences 配置界面,然後Profiles -> Text -> Font -> Chanage Font
,選擇
Meslo LG M Regular for Powerline
字體
自動提示填充
這個功能非常的實用,可以提高我們的開發效率
先克隆zsh-autosuggestions
項目,到指定目錄:
$ git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
然後編輯vim ~/.zshrc
文件,找到plugins
配置,增加zsh-autosuggestions
插件。
iTerm2 快捷命令
命令 | 說明 |
---|---|
command + t | 新建標籤 |
command + w | 關閉標籤 |
command + 數字 command + 左右方向鍵 | 切換標籤 |
command + enter | 切換全屏 |
command + f | 查找 |
command + d | 垂直分屏 |
command + shift + d | 水平分屏 |
command + option + 方向鍵 command + [ 或 command + ] | 切換屏幕 |
command + ; | 查看歷史命令 |
command + shift + h | 查看剪貼板歷史 |
ctrl + u | 清除當前行 |
ctrl + l | 清屏 |
ctrl + a | 到行首 |
ctrl + e | 到行尾 |
ctrl + f/b | 前進後退 |
ctrl + p | 上一條命令 |
ctrl + r | 搜索命令歷史 |