Welcome, guest | Sign In | My Account | Store | Cart
#!/usr/bin/env python

"""
Python interpreter auto-completion and history.
Installation:

 $ wget http://code.activestate.com/recipes/578098/download/2/ -O ~/.pythonstart
 $ echo "export PYTHONSTARTUP=~/.pythonstart" >> ~/.bashrc
 $ source ~/.bashrc
"""

# Author: Giampaolo Rodola' <g.rodola [AT] gmail [DOT] com>
# License: MIT

if not hasattr(__name__, "__file__"):  # interpreter mode

    def autocomplete():
        import atexit
        import os
        import readline
        import rlcompleter
        history_path = os.path.expanduser("~/.pyhistory")
        def save_history():
           readline.set_history_length(10000)
           readline.write_history_file(history_path)
        if os.path.exists(history_path):
           readline.read_history_file(history_path)
        atexit.register(save_history)
        readline.parse_and_bind('tab: complete')

    autocomplete()
    del autocomplete

Diff to Previous Revision

--- revision 1 2012-04-07 13:09:16
+++ revision 2 2012-04-07 13:28:19
@@ -1,9 +1,12 @@
 #!/usr/bin/env python
 
 """
-Python interpreter autocompletion and history.
-Add this script in your home and add this line to ~/.bashrc
-export PYTHONSTARTUP=~/.pythonstart
+Python interpreter auto-completion and history.
+Installation:
+
+ $ wget http://code.activestate.com/recipes/578098/download/2/ -O ~/.pythonstart
+ $ echo "export PYTHONSTARTUP=~/.pythonstart" >> ~/.bashrc
+ $ source ~/.bashrc
 """
 
 # Author: Giampaolo Rodola' <g.rodola [AT] gmail [DOT] com>

History