说明蓝色=命令名称

      浅绿=命令参数

      浅蓝=选项

      紫色=目录

      系统环境:CentOS  5.8  x86_64

      Python版本:2.7.3

在用户宿主目录建立 .pythonstartup 文件内容如下:

 
  1. # python startup file  
  2. import readline  
  3. import rlcompleter  
  4. import atexit  
  5. import os  
  6. # tab completion  
  7. readline.parse_and_bind('tab: complete')  
  8. # history file  
  9. histfile = os.path.join(os.environ['HOME'], '.pythonhistory')  
  10. try:  
  11.     readline.read_history_file(histfile)  
  12. except IOError:  
  13.     pass  
  14. atexit.register(readline.write_history_file, histfile)  
  15. del os, histfile, readline, rlcompleter  

在宿主目录的 .bashrc 文件中加入环境变量:

echo "export PYTHONSTARTUP=~/.pythonstartup" >> ~/.bashrc

退出重新登录,效果如图: