X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/519d679d1fcc4b2678384bc41ed84466f43c5477..807c317e99426f8379fc55fc4d4bc98e67ec0f41:/dot/ipython-config.py diff --git a/dot/ipython-config.py b/dot/ipython-config.py index 1555bba..1a8c25b 100644 --- a/dot/ipython-config.py +++ b/dot/ipython-config.py @@ -1,6 +1,10 @@ ### -*-python -*- -import pygments as PYG +try: import pygments as PYG +except: PYG = None +try: import prompt_toolkit as PTK +except: PTK = None + c = get_config() ## Simple stuff. @@ -14,33 +18,43 @@ c.InteractiveShell.colors = 'Linux' c.TerminalIPythonApp.display_banner = False c.TerminalInteractiveShell.confirm_exit = False c.TerminalInteractiveShell.display_completions = 'readlinelike' +c.TerminalInteractiveShell.term_title = False ## Syntax colouring. -T = PYG.token -c.TerminalInteractiveShell.highlighting_style = 'emacs' -c.TerminalInteractiveShell.highlighting_style_overrides = { - T.Keyword: 'bold #fff', - T.Comment: 'italic #54ff9f', - T.Literal.Number: '#ffff00', - T.Literal.String: '#87ceff', - T.Literal.String.Escape: '#87ceff', - T.Literal.String.Interpol: '#87ceff', - T.Name: '#fff', - T.Name.Builtin: '#fff', - T.Name.Class: '#fff', - T.Name.Constant: 'italic #fff', - T.Name.Decorator: '#fff', - T.Name.Exception: '#fff', - T.Name.Function: '#fff', - T.Name.Function.Magic: '#fff', - T.Name.Label: '#fff', - T.Name.Namespace: '#fff', - T.Name.Variable: '#fff', - T.Name.Variable.Class: '#fff', - T.Name.Variable.Global: '#fff', - T.Name.Variable.Instance: '#fff', - T.Name.Variable.Magic: '#fff', - T.Operator: '#eec591', - T.Operator.Word: 'bold #fff', - T.Punctuation: '#eec591' -} +if PYG and getattr(PYG, 'token', None): + T = PYG.token + c.TerminalInteractiveShell.highlighting_style = 'emacs' + c.TerminalInteractiveShell.highlighting_style_overrides = { + T.Keyword: 'bold #fff', + T.Comment: 'italic #54ff9f', + T.Literal.Number: '#ffff00', + T.Literal.String: '#87ceff', + T.Literal.String.Escape: '#87ceff', + T.Literal.String.Interpol: '#87ceff', + T.Name: '#fff', + T.Name.Builtin: '#fff', + T.Name.Class: '#fff', + T.Name.Constant: 'italic #fff', + T.Name.Decorator: '#fff', + T.Name.Exception: '#fff', + T.Name.Function: '#fff', + T.Name.Function.Magic: '#fff', + T.Name.Label: '#fff', + T.Name.Namespace: '#fff', + T.Name.Variable: '#fff', + T.Name.Variable.Class: '#fff', + T.Name.Variable.Global: '#fff', + T.Name.Variable.Instance: '#fff', + T.Name.Variable.Magic: '#fff', + T.Operator: '#eec591', + T.Operator.Word: 'bold #fff', + T.Punctuation: '#eec591', + } + +if PYG and PTK: + d = { + PTK.token.Token.MatchingBracket: '', + PTK.token.Token.MatchingBracket.Cursor: '', + PTK.token.Token.MatchingBracket.Other: 'bg:#006400' + } + c.TerminalInteractiveShell.highlighting_style_overrides.update(d)