X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=blobdiff_plain;f=rainbowstream%2Finteractive.py;h=47a257633a68a8685e68d18014d5ae5bd9ce5f10;hp=b7fabbcba728ec21b62c884fbfbdfed5c9b53595;hb=1e9794859fb00052587ab17a4f472bd62aea7f65;hpb=d51b4107ae3b0ac00b207ff8c79a85ed20b819be diff --git a/rainbowstream/interactive.py b/rainbowstream/interactive.py index b7fabbc..47a2576 100644 --- a/rainbowstream/interactive.py +++ b/rainbowstream/interactive.py @@ -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