Mac下配置ZSH

先來看一下效果, 容許我用一下官方圖片node

Paste_Image.png

1. 什麼是zsh, oh-my-zsh

zsh是Z Shell, 功能很強大可是太複雜,因此就出現了優化版的oh-my-zshgit

2. 檢查zsh

zsh --version;

若是存在, 則說明已安裝, 直接跳過本步驟 (mac 自帶Z Shell)github

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

3. 安裝oh-my-zsh

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

若是遇到問題, 能夠直接copy上面的sh文件, 而後download, 本地執行sh命令npm

4. 安裝iterm2

更強大的終端工具, 替換系統terminal, 與oh-my-zsh配合起來使用更完美
具體功能能夠訪問iterm2官網bash

5. 字體安裝

爲了不有些oh-my-zsh主題的字體亂碼問題, 最好設置iterm2的font爲powerline類的字體, 本身search一下
字體傳送門, 按README進行下載安裝.
Paste_Image.pngcurl

clipboard.png

6. oh-my-zsh主題修改

修改 ~/.zshrc 下的 ZSH_THEME 字段, 如ZSH_THEME="agnoster", 流行主題之一. 主題庫傳送門.工具

7. oh-my-zsh插件

插件安裝, 目錄到入~/.oh-my-zsh/plugins字體

# zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions

# zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting

修改 ~/.zshrc 下的plugins字段, 如優化

plugins=(git homebrew node npm zsh-autosuggestions zsh-syntax-highlighting)

更多插件去google搜插件名安裝google

8. 兼容.bash_profile

zsh安裝後, .bash_profile下設置的環境變量和alias會失效, 須要在~/.zshrc文件裏添加以下:

source .bash_profile

9. 切換默認終端

chsh -s /bin/zsh

切回bash能夠用

chsh -s /bin/bash
相關文章
相關標籤/搜索