mac終端利器----iterm2

MAC終端神器iterm2——告別黑白

最終效果:

image

箭頭不顯示

# clone
git clone https://github.com/powerline/fonts.git
# install
cd fonts
./install.sh

實(shí)現(xiàn)步驟

1. 下載iTerm2

官網(wǎng)下載:https://www.iterm2.com/

安裝完成后,在/bin目錄下會(huì)多出一個(gè)zsh的文件。

Mac系統(tǒng)默認(rèn)使用dash作為終端,可以使用命令修改默認(rèn)使用zsh:

chsh -s /bin/zsh

zsh完美代替bash,具體區(qū)別可查看:《Zsh和Bash區(qū)別》

iterm2的原始界面

image

2. 替換背景圖片

打開路徑:iterm2 -> Preferences -> Profiles -> window -> Background Image

選擇一張自己喜歡的壁紙即可

可以通過Blending調(diào)節(jié)壁紙的透明度: 透明度為0的時(shí)候,背景變?yōu)榧兩?黑色)

我個(gè)人比較喜歡扁平化的壁紙,喜歡的朋友可以來這里看看:
《有哪些優(yōu)雅的 Windows 10 壁紙?》

3. 安裝Oh my zsh

zsh的功能極其強(qiáng)大,只是配置過于復(fù)雜,通過Oh my zsh可以很快配置zsh。

這里只做簡(jiǎn)單的配置,如需要深入了解,可以查看:《oh-my-zsh,讓你的終端從未這么爽過》

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

# 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的一個(gè)維護(hù)命令

安裝powerline:

pip install powerline-status --user

5. 安裝PowerFonts

在常用的位置新建一個(gè)文件夾,如:~/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

執(zhí)行結(jié)果如下:

image

安裝好字體庫之后,我們來設(shè)置iTerm2的字體,具體的操作是:

iTerm2 -> Preferences -> Profiles -> Text

在Font區(qū)域選中Change Font,然后找到Meslo LG字體。

image

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

在OpenSource目錄下執(zhí)行git clone命令:

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

cd solarized/iterm2-colors-solarized/
open .

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

image

再次進(jìn)入iTerm2 -> Preferences -> Profiles -> Colors -> Color Presets中根據(jù)個(gè)人喜好選擇.

7. 安裝主題

在OpenSource目錄下執(zhí)行git clone命令:

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

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

執(zhí)行上面的命令會(huì)將主題拷貝到oh my zsh的themes.

執(zhí)行命令打開zshrc配置文件,將ZSH_THEME后面的字段改為agnoster

vi ~/.zshrc
image

我這里簡(jiǎn)單說一下vim的一些操作命令,不熟悉的可以看看:

鍵盤i: 進(jìn)入可編輯模式,最下面顯示-- INSERT --

image

鍵盤esc: 退出編輯模式

shift + : : 執(zhí)行命令操作

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

此時(shí)command+Q或source配置文件后,iTerm2變了模樣:

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

8. 安裝高亮插件

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

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

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

這時(shí)我們?cè)俅未蜷_zshrc文件進(jìn)行編輯。找到plugins,此時(shí)plugins中應(yīng)該已經(jīng)有了git,我們需要把高亮插件也加上:

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

請(qǐng)務(wù)必保證插件順序,zsh-syntax-highlighting必須在最后一個(gè)。

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

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

按一下esc調(diào)出vi命令,輸入:wq保存并退出vi模式。

執(zhí)行命令使剛才的修改生效:

source ~/.zshrc

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

9. 可選擇、命令補(bǔ)全

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

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

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

找到plugins,加上這個(gè)插件即可:

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

插件效果:

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

可以自己調(diào)整字體顏色。

Preferences -> Profiles -> Colors 中有Foreground是標(biāo)準(zhǔn)字體顏色,ANSI Colors中Bright的第一個(gè)是補(bǔ)全的字體顏色。

刪除命令歷史:

// 刪除命令歷史
rm ~/.bash_history 

文章內(nèi)容參考 《iTerm2 + Oh My Zsh 打造舒適終端體驗(yàn)》

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容