您好,登錄后才能下訂單哦!
一個(gè)高效的開發(fā)環(huán)境,無疑對我們?nèi)粘9ぷ饔芯薮蟮膸椭?,時(shí)間就是靠著這些微小的細(xì)節(jié)而節(jié)省出來的。
接下來,我將給大家講解如何配置zsh+incr,打造終極高效的開發(fā)環(huán)境。
首先,先看一下效果:
想要你的shell有這樣的效果,首先滿足下面的條件:
安裝oh-my-zsh
下載incr
把插件執(zhí)行shell 寫到.zshrc 配置文件中
廢話不多說,我直接上詳細(xì)步驟:
1、安裝zsh
Mac : 直接看下一節(jié)
Redhat/centos :sudo yum install zsh
Ubuntu :sudo apt-get install zsh
安裝完成后執(zhí)行:
chsh -s /bin/zsh
2、安裝oh my zsh
自動(dòng)安裝:
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
手動(dòng)安裝:
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zshcp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
3、下載incr
下載地址: http://mimosa-pudica.net/zsh-incremental.html
為了防止該網(wǎng)址將來不能訪問,因此我把代碼摘錄如下:
# Incremental completion for zsh # by y.fujii <y-fujii at mimosa-pudica.net>, public domain autoload -U compinit zle -N self-insert self-insert-incr zle -N vi-cmd-mode-incr zle -N vi-backward-delete-char-incr zle -N backward-delete-char-incr zle -N expand-or-complete-prefix-incr compinit bindkey -M viins '^[' vi-cmd-mode-incr bindkey -M viins '^h' vi-backward-delete-char-incr bindkey -M viins '^?' vi-backward-delete-char-incr bindkey -M viins '^i' expand-or-complete-prefix-incr bindkey -M emacs '^h' backward-delete-char-incr bindkey -M emacs '^?' backward-delete-char-incr bindkey -M emacs '^i' expand-or-complete-prefix-incr unsetopt automenu compdef -d scp compdef -d tar compdef -d make compdef -d java compdef -d svn compdef -d cvs # TODO: # cp dir/ now_predict=0 function limit-completion { if ((compstate[nmatches] <= 1)); then zle -M "" elif ((compstate[list_lines] > 6)); then compstate[list]="" zle -M "too many matches." fi } function correct-prediction { if ((now_predict == 1)); then if [[ "$BUFFER" != "$buffer_prd" ]] || ((CURSOR != cursor_org)); then now_predict=0 fi fi } function remove-prediction { if ((now_predict == 1)); then BUFFER="$buffer_org" now_predict=0 fi } function show-prediction { # assert(now_predict == 0) if ((PENDING == 0)) && ((CURSOR > 1)) && [[ "$PREBUFFER" == "" ]] && [[ "$BUFFER[CURSOR]" != " " ]] then cursor_org="$CURSOR" buffer_org="$BUFFER" comppostfuncs=(limit-completion) zle complete-word cursor_prd="$CURSOR" buffer_prd="$BUFFER" if [[ "$buffer_org[1,cursor_org]" == "$buffer_prd[1,cursor_org]" ]]; then CURSOR="$cursor_org" if [[ "$buffer_org" != "$buffer_prd" ]] || ((cursor_org != cursor_prd)); then now_predict=1 fi else BUFFER="$buffer_org" CURSOR="$cursor_org" fi echo -n "\e[32m" else zle -M "" fi } function preexec { echo -n "\e[39m" } function vi-cmd-mode-incr { correct-prediction remove-prediction zle vi-cmd-mode } function self-insert-incr { correct-prediction remove-prediction if zle .self-insert; then show-prediction fi } function vi-backward-delete-char-incr { correct-prediction remove-prediction if zle vi-backward-delete-char; then show-prediction fi } function backward-delete-char-incr { correct-prediction remove-prediction if zle backward-delete-char; then show-prediction fi } function expand-or-complete-prefix-incr { correct-prediction if ((now_predict == 1)); then CURSOR="$cursor_prd" now_predict=0 comppostfuncs=(limit-completion) zle list-choices else remove-prediction zle expand-or-complete-prefix fi }
4、執(zhí)行如下命令:
cd ~/.oh-my-zsh/plugins/ mkdir -p incr cd incr touch incr-0.2.zsh (將上面鏈接中的代碼復(fù)制粘貼到incr-0.2.zsh文件中) chmod 777 incr-0.2.zsh
5、配置 .zshrc 文件:
vim ~/.zshrc
末尾加入
source ~/.oh-my-zsh/plugins/incr/incr*.zsh
6、 source ~/.zshrc #使其立即生效
7、到此配置完畢,關(guān)閉當(dāng)前shell終端窗口,再重新打開,即可看到效果。是不是覺得以前使用的bash弱爆了呢!
另附上 on my zsh 的主題鏈接,喜歡折騰的兄弟拿去慢慢修改吧:
https://github.com/robbyrussell/oh-my-zsh/wiki/themes
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。