close
譯者:Nica < nicaliu at gmail dot com >,如有版權問題,煩請來信告知。



我 Linux 的機器裝好的第一件事,就是去更新 .inputrc 與 .bashrc 檔,讓它支援 "Enhanced Bash"。這個改善動作乍看之下沒什麼,但其實它能夠大大增進我使用 shell 的效率。







啟用 "Enhanced Bash" 可達到的主要功能有:



1. 僅需部份輸入,即可輕鬆比對先前鍵入的指令。它的作法是,只要輕鬆輸入幾個命令開始字母,就會出現提示表單,以捲軸的方式顯示所有歷史指令。



2. 各終端畫面間共享歷史指令:當你關閉終端畫面後,並不會漏失指令的歷史紀錄。



3. 令 grep 以不同顏色顯示,凸顯相符的字。這很好用。



欲啟用此功能,請開啟你的 ~/.inputrc 檔,然後輸入這些:



# -------- Bind page up/down wih history search ---------

"\e[5~": history-search-backward

"\e[6~": history-search-forward




# -------- more sane command matching --------------------

#do not show hidden files in the list

set match-hidden-files off




#removes the annoying "-- more --" prompt for long lists

set page-completions off




#show the "Display all 123 possibilities? (y or n)" prompt

# only for really long lists

set completion-query-items 350




# show the list at first TAB, instead of beeping and

# waiting for a second TAB to do that

# uncomment next line to enable

#set show-all-if-ambiguous on




(以上程式碼取自:http://www.amirwatad.com/blog/archives/2009/01/30/enhanced-bash/)



然後把下面內容加入 ~/.bashrc :



#Make sure all terminals save history

shopt -s histappend

PROMPT_COMMAND="history -a; $PROMPT_COMMAND"




#Increase history size

export HISTSIZE=1000

export HISTFILESIZE=1000




#Use GREP color features by default

export GREP_OPTIONS='--color=auto'




(以上程式碼取自:http://www.amirwatad.com/blog/archives/2009/01/30/enhanced-bash/)



要瞭解更多內容,你可以到 https://wiki.ubuntu.com/Spec/EnhancedBash 看看。

希望你也覺得這個很有用。



原文出處:Enhanced Bash
arrow
arrow
    全站熱搜

    nicaliu 發表在 痞客邦 留言(0) 人氣()