#!/usr/bin/env python
import os
import sys
import IPython

banner = 'IPython {} - Python {}\n'
python_version = sys.version.split(' ', 1)[0]
ipython_version = IPython.__version__

c = get_config()
c.BaseIPythonApplication.extra_config_file = f"{os.getcwd()}/.ipython_config.py"
c.TerminalInteractiveShell.separate_in = ''
c.TerminalInteractiveShell.banner1 = banner.format(ipython_version, python_version)

if int(ipython_version.split(".")[0]) >= 5:
    from IPython.terminal.prompts import Prompts, Token

    class MyPrompts(Prompts):

        def in_prompt_tokens(self, cli=None):
            return [(Token.Prompt, '>>> ')]

        def continuation_prompt_tokens(self, cli=None, width=None):
            if width is None:
                width = self._width()
            return [
                (Token.Prompt, (' ' * (width - 5)) + '... '),
            ]

        def out_prompt_tokens(self):
            return []

    c.TerminalInteractiveShell.prompts_class = MyPrompts
else:
    c.PromptManager.out_template = ''
    c.PromptManager.in2_template = '... '
    c.PromptManager.justify = False
    c.PromptManager.in_template = '>>> '
