mac上zsh|macvim|powerline的安裝與配置
阿新 • • 發佈:2019-01-22
效果圖
實際上我主要用powerline來美化或加強了兩個東西,分別是zsh和vim而這兩個是需要安裝不同的powerline的,搜尋的話,一個是powerline-shell,一個是powerline或vim-powerline,安裝後,效果如下圖:這個是zsh裡的效果
這個是在macvim裡的效果
安裝與配置
1. zsh
官網:http://ohmyz.sh/,簡單介紹下,就是開源的shell擴充套件,讓你的shell支援高亮,git,快速跳轉什麼的,因為要做sh終結者,所以是z兩各安裝方式,需先安裝git,安裝完後,重啟終端搞定
curl -L http://install.ohmyz.sh | sh wget --no-check-certificate http://install.ohmyz.sh -O - | sh
2. powerline-shell
官網:https://github.com/milkbikis/powerline-shell,github的說明已經很清楚了,步驟大體如下:- git clone https://github.com/milkbikis/powerline-shell,先clone到一個檔案裡
- 將資料夾中的config.py.dist複製更名為config.py
- ./install.py,安裝
- ln -s <path/to/powerline-shell.py> ~/powerline-shell.py,在主目錄下建立link,或將其到path,好吧,我上面那個還在。。
- pip install argparse,python2.6安裝這個
- 然後,修改zsh的配置檔案.zshrc,在最後新增如下內容,完成後,用source .zshrc更新配置即可
function powerline_precmd() { export PS1="$(~/powerline-shell.py $? --shell zsh 2> /dev/null)" } function install_powerline_precmd() { for s in "${precmd_functions[@]}"; do if [ "$s" = "powerline_precmd" ]; then return fi done precmd_functions+=(powerline_precmd) } install_powerline_precmd
- 最後,出現亂碼的情況下,安裝字型https://github.com/Lokaltog/powerline-fonts,然後在終端的偏好設定裡更改字型就可以了
3. 安裝macvim
官網:https://github.com/b4winckler/macvim,安裝過程如下,其實就一條命令,需先安裝有brew,brew的安裝方法就不說了啊brew install macvim --env-std --override-system-vim
安裝完成之後,我也鬱悶了,安裝上了嗎,怎麼啟動呢。。嘻嘻,直接敲mvim就可以了,好像第一次啟動後會預設幫你把預設的vim鏈到這個上,然後,以後直接vim也是mvim了,這裡再說一下吧,個人不太建議再在macvim上裝太多的外掛什麼的,如側邊檔案目錄,各種快捷操作,配色什麼的,一句話說就是:我不想花很大的力氣,把macvim打扮成sublime,還增加了操作的記憶負擔,而且還會減慢啟動速度。所以我讓它還是vim,就是好看一點,好用一些就行了
4. 安裝powerline(vim)
官網:http://powerline.readthedocs.org,裡面有安裝過程,但我安裝完後,不太一樣沒有script資料夾,所以又從github里弄了一份,步驟如下:- pip install --user git+git://github.com/Lokaltog/powerline,沒錯,還是一條命令。。但需要先安裝pip
- pip install -e --user {path_to_powerline},會為使用者建立快捷方式到.local/bin裡,不行的話就自己建立,如果這兩步不通的話,可以按下面的做
- https://github.com/Lokaltog/powerline,用git clone出這個官網專案的原始碼到一個目錄中
- 修改~/.vimrc,沒有的話,自己建立,上面兩個方式都需要你知道powerline的目錄,配置裡會用到,配置如下:
set rtp+=/Users/cungen/sdk/system/powerline/powerline/bindings/vim
set guifont=Sauce\ Code\ Powerline:h14.5
set laststatus=2
set encoding=utf-8
set t_Co=256
set number
set fillchars+=stl:\ ,stlnc:\
set term=xterm-256color
set termencoding=utf-8
set background=light
注意,要將目錄改為你安裝powerline的目錄,字型改成你要使用的字型,也需是從powerline的字型裡下載的字型,儲存後,source .vimrc使用配置生效,再次啟動vim,即可哈哈。。