MAC終端神器iterm2

故事一開始是這樣的:

在裝nginx的時候請教了一下後端的同事,被嘲笑了一下,黑白的界面如下圖,哈哈,一直懶得弄。記錄一下配置過程吧

 

  1. 剛開始的界面:

一.首先是配置了一下終端的背景圖,自己選了一個電影裏的主題如下:(裝B並沒有什麼卵用)

1. 下載iTerm2

官網下載:https://www.iterm2.com/

安裝完成後,在/bin目錄下會多出一個zsh的文件。

Mac系統默認使用dash作爲終端,可以使用命令修改默認使用zsh:

chsh -s /bin/zsh

2.iterm2---->PreFerences-->Profiles-->window-->Backgound image(雙擊替換)

效果如下:

 

下面參考一位博友的吧,懶得寫了:

3. 安裝Oh my zsh

zsh的功能極其強大,只是配置過於複雜,通過Oh my zsh可以很快配置zsh。

這裏只做簡單的配置,如需要深入瞭解,可以查看:《oh-my-zsh,讓你的終端從未這麼爽過》

安裝方法有兩種,可以使用curl或wget,看自己環境或喜好:

# curl 安裝方式
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# wget 安裝方式
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

oh-my-zsh開源地址:《oh-my-zsh》

 

4. 安裝PowerLine

首先先安裝pip命令:

sudo easy_install pip

pip是python的一個維護命令

安裝powerline:

pip install powerline-status --user

5. 安裝PowerFonts

在常用的位置新建一個文件夾,如:~/Desktop/OpenSource/

OpenSource文件夾下下載PorweFonts:

# git clone
git clone https://github.com/powerline/fonts.git --depth=1

# cd to folder
cd fonts

# run install shell
./install.sh

執行結果如下:

安裝好字體庫之後,我們來設置iTerm2的字體,具體的操作是:

iTerm2 -> Preferences -> Profiles -> Text

在Font區域選中Change Font,然後找到Meslo LG字體。

6. 安裝配色方案(可跳過)

在OpenSource目錄下執行git clone命令:

git clone https://github.com/altercation/solarized

cd solarized/iterm2-colors-solarized/
open .

在打開的finder窗口中,雙擊Solarized Dark.itermcolors和Solarized Light.itermcolors即可安裝明暗兩種配色:

再次進入iTerm2 -> Preferences -> Profiles -> Colors -> Color Presets中根據個人喜好選擇.

7. 安裝主題

在OpenSource目錄下執行git clone命令:

git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git

cd oh-my-zsh-agnoster-fcamblor/
./install

執行上面的命令會將主題拷貝到oh my zsh的themes.

執行命令打開zshrc配置文件,將ZSH_THEME後面的字段改爲agnoster

vi ~/.zshrc

我這裏簡單說一下vim的一些操作命令,不熟悉的可以看看:

鍵盤i: 進入可編輯模式,最下面顯示-- INSERT --

鍵盤esc: 退出編輯模式

shift + : : 執行命令操作

輸入wq: 保存當前更改。如果僅僅退出不保存,可以輸入q

此時command+Q或source配置文件後,iTerm2變了模樣:

https://raw.githubusercontent.com/sirius1024/pubimgs/master/blogs/iterm2/12.png

8. 安裝高亮插件

這是oh my zsh的一個插件,安裝方式與theme大同小異:

cd ~/.oh-my-zsh/custom/plugins/

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
vi ~/.zshrc

這時我們再次打開zshrc文件進行編輯。找到plugins,此時plugins中應該已經有了git,我們需要把高亮插件也加上:

https://raw.githubusercontent.com/sirius1024/pubimgs/master/blogs/iterm2/13.png

請務必保證插件順序,zsh-syntax-highlighting必須在最後一個。

然後在文件的最後一行添加:

source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

按一下esc調出vi命令,輸入:wq保存並退出vi模式。

執行命令使剛纔的修改生效:

source ~/.zshrc

所有配置至此結束。下面提供另外的功能

9. 可選擇、命令補全

跟代碼高亮的安裝方式一樣,這也是一個zsh的插件,叫做zsh-autosuggestion,用於命令建議和補全。

cd ~/.oh-my-zsh/custom/plugins/

git clone https://github.com/zsh-users/zsh-autosuggestions
vi ~/.zshrc

找到plugins,加上這個插件即可:

https://raw.githubusercontent.com/sirius1024/pubimgs/master/blogs/iterm2/15.png

插件效果:

https://raw.githubusercontent.com/sirius1024/pubimgs/master/blogs/iterm2/16.png

有同學說補全命令的字體不太清晰,與背景顏色太過相近,其實可以自己調整一下字體顏色。

Preferences -> Profiles -> Colors 中有Foreground是標準字體顏色,ANSI Colors中Bright的第一個是補全的字體顏色。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章