Update README.md
[rainbowstream.git] / rainbowstream / interactive.py
index b7fabbcba728ec21b62c884fbfbdfed5c9b53595..47a257633a68a8685e68d18014d5ae5bd9ce5f10 100644 (file)
@@ -1,5 +1,9 @@
 import readline
 import rlcompleter
+import os.path
+
+from .config import *
+
 
 class RainbowCompleter(object):
 
@@ -49,6 +53,31 @@ class RainbowCompleter(object):
         return response
 
 
+def get_history_items():
+    """
+    Get all history item
+    """
+    return [
+        readline.get_history_item(i)
+        for i in xrange(1, readline.get_current_history_length() + 1)
+    ]
+
+
+def read_history():
+    """
+    Read history file
+    """
+    if os.path.isfile(HISTORY_FILENAME):
+        readline.read_history_file(HISTORY_FILENAME)
+
+
+def save_history():
+    """
+    Save history to file
+    """
+    readline.write_history_file(HISTORY_FILENAME)
+
+
 def init_interactive_shell(d):
     """
     Init the rainbow shell