@@ -0,0 +1,1788 @@
+# -*- coding:utf-8 -*-%0A%0Aimport os%0Aimport sys%0A%0Asys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))%0A%0Aimport prompt_toolkit%0A%0Afrom prompt_toolkit.history import FileHistory%0Afrom prompt_toolkit.completion import Completion%0Afrom prompt_toolkit.contrib.completers import WordCompleter%0Afrom tpl import path%0A%0A%0Ahistory = FileHistory(os.path.join(path.HOME, '.templates', 'tpl.history'))%0A%0A%0Aclass WordCompleterWithHistory(WordCompleter):%0A    def __init__(self, words=None, *args, **kwargs):%0A        words = words or %5B%5D%0A        super(WordCompleterWithHistory, self).__init__(words, *args, **kwargs)%0A%0A    def word_matches(self, word_before_cursor, word):%0A        %22%22%22 True when the word before the cursor matches. %22%22%22%0A        if self.ignore_case:%0A            word = word.lower()%0A%0A        if self.match_middle:%0A            return word_before_cursor in word%0A        else:%0A            return word.startswith(word_before_cursor)%0A%0A    def get_completions(self, document, complete_event):%0A        if self.sentence:%0A            word_before_cursor = document.text_before_cursor%0A        else:%0A            word_before_cursor = document.get_word_before_cursor(WORD=self.WORD)%0A%0A        if self.ignore_case:%0A            word_before_cursor = word_before_cursor.lower()%0A%0A        for completion in super(WordCompleterWithHistory, self).get_completions(document, complete_event):%0A            yield completion%0A        for record in history:%0A            if self.word_matches(word_before_cursor, record):%0A                display_meta = self.meta_dict.get(record, '')%0A                yield Completion(record, -len(word_before_cursor), display_meta=display_meta)%0A%0A%0Adef prompt(message, type=None, default=None, completer=None, multiline=False):%0A    pass%0A%0A%0Adef prompt_list():%0A    pass%0A%0A%0Adef prompt_path():%0A    pass%0A%0A

add completer according to words and history