Create a new ~/.pythonstartup file and write the following:
$ cat ~/.pythonstartup Import sysimport readlineimport rlcompleterif sys.platform = = ' Darwin ' and sys.version_info[0] = = 2 : Readline.parse_and_bind ("Bind ^i Rl_complete") else:readline.parse_and_bind ("Tab:complete")
Then set the environment variable Pythonstartup, can be set in the ~/.bash_profile file of the home directory, append the following line. As follows:
Export pythonstartup= $HOME/.pythonstartup
Reload the ~/.bash_profile configuration file,
. ~/.bash_profile
Set up, you can enter the Python command line terminal, to verify that the tab completion can be done,
pythonPython 2.7.10 (default, oct 23 2015, 19:19:21) [gcc 4.1.7 Compatible Apple LLVM 6.8.0 (clang-500.0.11.5)] on darwintype "Help", "Copyright", "credits" or "license" for more information.>>> import sys>>> print sys.psys.path sys.platform sys.ps2 sys.path_hooks sys.prefix sys.py3kwarning sys.path_importer_cache sys.ps1 &nbSp; >>> print sys.p
Well, it is possible to complete the completion of the verification.
This article is from the "solid-state Drive" blog, make sure to keep this source http://lavenliu.blog.51cto.com/5060944/1791183
Python Command line tab completion for Mac system