1. 程式人生 > >【工具】終端 iterm2 + zsh + oh-my-zsh

【工具】終端 iterm2 + zsh + oh-my-zsh

iTerm2

Mac的終端不好用嗎,是時候換一款終端了了iTerm2,
下載:https://iterm2.com/
你要說好用在哪,可以看看這個
https://iterm2.com/features.html

zsh

zsh是shell語言型別,相容bash,提供強大的命令列功能,比如tab補全,自動糾錯功能等。缺點就是配置太麻煩,好在有一個叫做oh-my-zsh的開源專案,很好的彌補了這一缺陷,只需要修修改改配置檔案,就能很順手。

安裝zsh

檢視系統當前使用的shell

$ echo $SHELL
/bin/bash

檢視系統是否安裝了zsh

$ cat /etc/shells 
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh

沒有的話則安裝:

brew install zsh

切換shell為zsh

$ chsh -s /bin/zsh
Changing shell for root.
Shell changed.

重啟後,檢視當前shell

$ echo $SHELL
/bin/zsh

安裝 oh my zsh

oh-my-zsh原始碼是放在github上,先確保你的機器上已安裝了git和wget
沒wget則安裝:

brew install wget

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

成功介面:

____  / /_     ____ ___  __  __   ____  _____/ /_  
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ 
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / 
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  
                        /____/                       ....is now installed!
Please look over the ~/.zshrc file to select plugins, themes, and options.

p.s. Follow us at https://twitter.com/ohmyzsh.

p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.

接下來只需簡單的配置,就可以享受oh-my-zsh的強大
oh-my-zsh有很多漂亮的主題:
https://github.com/robbyrussell/oh-my-zsh/wiki/themes

我使用的主題是ys
修改主題:

$ vim ~/.zshrc

將ZSH_THEME改成ys

ZSH_THEME="ys"

更新配置:

$ source ~/.zshrc