Python command line Add Tab key Auto complete

Source: Internet
Author: User


system:red Hat Enterprise Linux Server release 5.6 (Tikanga)

1. Get the Python directory

[Email protected] ~]# Pythonpython 2.4.3 (#1, Dec, 17:24:35) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on Linux2typ E "Help", "copyright", "credits" or "license" for more information.>>> import sys>>> sys.path[", '/usr/ Lib64/python24.zip ', '/usr/lib64/python2.4 ', '/usr/lib64/python2.4/plat-linux2 ', '/usr/lib64/python2.4/lib-tk ', '/ Usr/lib64/python2.4/lib-dynload ', '/usr/lib64/python2.4/site-packages ', '/usr/lib64/python2.4/site-packages/ Numeric ', '/usr/lib64/python2.4/site-packages/gtk-2.0 ', '/usr/lib/python2.4/site-packages ']

Learn about the Python directory/usr/lib64/python2.4

2. Switch to the Python directory to write startup.py scripts to process Python <tab> events

The contents are as follows:

[[email protected] ~]# Cd/usr/lib64/python2.4/[[email protected] python2.4]# vi startup.py #!/usr/bin/python# python STA Rtup fileimport sysimport readlineimport rlcompleterimport atexitimport os# tab completionreadline.parse_and_bind (' tab : Complete ') # History filehistfile = Os.path.join (os.environ[' HOME '), '. Pythonhistory ') Try:readline.read_history_ File (histfile) except IOError:passatexit.register (Readline.write_history_file, histfile) del os, Histfile, ReadLine, Rlcompleter

3. Switch to the main directory to add the environment variable and make it effective

[[email protected] python2.4]# cd[[email protected] ~]# vi. BASHRC #在最后一行添加: #for pythonexport pythonstartup=/usr/lib64/ python2.4/startup.py
[[email protected] ~]# source. BASHRC

4. Verification

[Email protected] ~]# Pythonpython 2.4.3 (#1, Dec, 17:24:35) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on Linux2typ                 E "Help", "copyright", "credits" or "license" for more information.>>> import sys>>> Sys.pathsys.path Sys.path_importer_cachesys.path_hooks >>> Sys.path


This article is from the "Legendary Library sub" blog, please be sure to keep this source http://chason.blog.51cto.com/9078447/1610304

Python command line Add Tab key Auto complete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.