Browse Source

Implemented readline support in trs shell.

Sander Mathijs van Veen 14 years ago
parent
commit
8fa8e9234b
1 changed files with 19 additions and 0 deletions
  1. 19 0
      main.py

+ 19 - 0
main.py

@@ -1,5 +1,24 @@
 #!/usr/bin/python
+
+def init_readline():
+    import os
+    try:
+        import readline
+    except ImportError:
+        return
+
+    histfile = os.path.join(os.path.expanduser("~"), ".trs_hist")
+
+    try:
+        readline.read_history_file(histfile)
+    except IOError:
+        pass
+
+    import atexit
+    atexit.register(readline.write_history_file, histfile)
+
 from src.parser import main
 
 if __name__ == '__main__':
+    init_readline()
     main()