image viewer + input history + follow + unfollow
[rainbowstream.git] / rainbowstream / interactive.py
index b7fabbc..47a2576 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