Linux設定python自動tab自動補全

__Cheny發表於2015-04-02

1.安裝readline模組。

sudo apt-get install readline*

2.建立檔案~/.pythonstartup,內容如下

# python startup file
import sys
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind('tab: complete')
# history file
histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
try:
    readline.read_history_file(histfile)
except IOError:
    pass
atexit.register(readline.write_history_file, histfile)


del os, histfile, readline, rlcompleter 
3.在~/.bash_profile中新增環境變數

export PYTHONSTARTUP=~/.pythonstartup
4.重新整理配置

source .bash_profile




相關文章